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('您输入的邮箱地址不合法')

 

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐