第一题
# -*- coding: utf-8 -*- import re def is_valid_email(addr): return re.match(r'^[\w.<>]+@\w+\.com$',addr)!=None
第二题
# -*- coding: utf-8 -*- import re def is_valid_email(addr): return re.match(r'^[\w.<>\s]+@\w+\.[org]|[com]$',addr)!=None def name_of_email(addr): if is_valid_email(addr): if re.match(r'^\<\w+\>*',addr): return re.match(r'^<([\w\.\s]+)>@*',addr)[1] else: return re.match(r'^([\w\.]+)@*',addr)[1] else: raise ValueError
Sign in to make a reply
状元刚01
第一题
第二题