#验证邮箱(版本一)
import re
email = input('please input email:') if re.match(r'^([a-zA-Z_]+)(._a-zA-Z)|([a-zA-Z_]+)@([0-9a-zA-Z.]+)$',email): print(email) else: print('wrong email')
#验证并提取出带名字的Email地址(版本二)
email = input('please input email:') reemail = re.compile(r'^([a-zA-Z0-9\s\<>]+)\s([a-zA-Z.0-9_]+)@([0-9a-zA-Z.]+)$') if reemail.match(email): print(reemail.match(email).group(1)) else: print('wrong email')
"@"后面的部分不严谨,难道可以输入"somone@..."?
Sign in to make a reply
永恆生命
#验证邮箱(版本一)
import re
email = input('please input email:') if re.match(r'^([a-zA-Z_]+)(._a-zA-Z)|([a-zA-Z_]+)@([0-9a-zA-Z.]+)$',email): print(email) else: print('wrong email')
#验证并提取出带名字的Email地址(版本二)
import re
email = input('please input email:') reemail = re.compile(r'^([a-zA-Z0-9\s\<>]+)\s([a-zA-Z.0-9_]+)@([0-9a-zA-Z.]+)$') if reemail.match(email): print(reemail.match(email).group(1)) else: print('wrong email')