我们老师常说,学习python的最好办法,就是多多的敲,并不是多多的思考,所以,兄弟们只有卷起袖子来干困难就会躲在一边。
import re
str='张三 张四 王小玲 13208888123 4819599 zhangtom@126.com 676197687211@qq.com 1999-03-26 《凡人修仙传》《水浒传》'
emails= re.findall(r'[0-9a-zA-Z_]{0,19}@[0-9a-zA-Z]{1,13}.[com,cn,net]{1,3}', str)
mobiles = re.findall(r'1d{10}', str)
books= re.findall(r'《.+?》',str)
date= re.findall(r'(d{4}-d{1,2}-d{1,2})',str)
print('邮箱账号:{}'.format(emails),'n'+'手机号码:{}'.format(mobiles),'n'+'小说名称:{}'.format(books),'n'+'日期:{}'.format(date))
你觉得这个代码怎么样。投票一下。



