import re def func(email): #m = re.match(r'^(\w*.?\w*@(gmail|microsoft).(com|org))$',email) m = re.match(r'^(<[a-zA-Z]*\s*[a-zA-Z]*>\s+)?(\w+\.?\w+)(@\w+)(.com|.org)$',email) if m: print('邮箱地址输入正确') if m.group(1) != None: print(email) else: print('邮箱地址输入错误') func('someone@gmail.com') func('bill.gates@microsoft.com') func('<Tom Paris> tom@voyager.org') func('<Bill> bill.gates@microsoft.com')
Sign in to make a reply
会点儿pop的王天幸