admin管理员组

文章数量:1530060

python编写程序,校验键盘录入的电子邮箱是否合法,并测试。

def check_email(email):
    postfix = email[-4:]
    for i in email:
        if len(email)>10 and i == '@' and postfix == '' 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('您输入的邮箱地址不合法')

 

本文标签: 电子邮箱是否合法键盘测试程序