Discuss / Python / 作业1

作业1

Topic source

lldhsds

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

import re

def is_valid_email(addr):
# re_addr = re.compile(r'^[a-zA-Z0-9\.]+@[a-zA-Z]+\.com$')
re_addr = re.compile(r'^[\d\w\.]+@[\w]+\.com$')
if re_addr.match(addr):
return True

# 测试:
assert is_valid_email('someone@gmail.com')
assert is_valid_email('bill.gates@microsoft.com')
assert not is_valid_email('bob#example.com')
assert not is_valid_email('mr-bob@example.com')
print('ok')


  • 1

Reply