编写程序,校验键盘录入的电子邮箱是否合法,并测试。
python编写程序,校验键盘录入的电子邮箱是否合法,并测试。def check_email(email):postfix = email[-4:]for i in email:if len(email)>10 and i == '@' and postfix == '.com' and i!=' ':return Trueif i.isalpha() == False and i.isdi
·
python编写程序,校验键盘录入的电子邮箱是否合法,并测试。
def check_email(email):
postfix = email[-4:]
for i in email:
if len(email)>10 and i == '@' and postfix == '.com' and i!=' ':
return True
if i.isalpha() == False and i.isdigit() == False:
if i != '.' and i != '@' and i != '_':
return False
email = input('请输入一个邮箱地址:')
result=check_email(email)
if result==True:
print('您输入的邮箱地址合法')
else:
print('您输入的邮箱地址不合法')
更多推荐
已为社区贡献1条内容
所有评论(0)