Discuss / Python / 第二题是要名字+email么

第二题是要名字+email么

Topic source

迷迷的蛋

#1 Created at ... [Delete] [Delete and Lock User]

1.

#!/usr/bin/python3.5
#
import re
auth_mail = input('input string:')
re_tt = re.compile(r'[\w\W]+\@[a-z]+\.[a-z]+')
if re_tt.match(auth_mail):
    print('%s is email' % (re_tt.match(auth_mail).group()))
else:
    print('not email')
[root@localhost python]# ./regul.py
input string:someone@gmail.com
someone@gamil.com is email
[root@localhost python]# ./regul.py
input strint:bill.gates@microsoft.com
bill.gates@microsoft.com is email

2. a, b = re.match(r'<([\w\s]+)\s[\w\s]+>\s([\w\W]+)', '<Tom Paris> tom@vosadas.org').groups() print('%s:%s' % (a, b)) Tom:tom@vosadas.org


  • 1

Reply