设为首页 加入收藏

TOP

Python基本练习题(二)
2019-02-19 18:08:08 】 浏览:216
Tags:Python 基本 习题
入的序列有误,请重新输入!
') continue elif choose.isalpha(): if choose.upper() == 'Q': print('good-bye!') break else: print('退出失败,您的输出有误') continue else: print('您的输入有误,请重新输入!') View Code

 

14、账号注册登录验证

while 1:
    username = input('请输出您需要注册的账号:')
    password = input('请输出您需要注册的密码:')
    if username.isalnum() and password.isalnum():
        print('可以注册√')
        username_new = input('请再次确认您需要注册的账号:')
        password_new = input('请再次确认您需要注册的密码:')
        if username_new == username and password_new == password:
            print('注册成功!')
            break
    else:
        input('注册信息有误,请重新输入\n')

username_file = open('Username', mode='a', encoding='utf-8')
password_file = open('Password', mode='a', encoding='utf-8')

username_file.write(username)
password_file.write(password)
username_file.close()
password_file.close()

for i in range(3):
    login_username = input('请登录用户名:')
    login_password = input('请登录密码:')
    username = open('Username', mode='r', encoding='utf-8')
    password = open('Password', mode='r', encoding='utf-8')
    read_user = username.read()
    read_pass = password.read()
    if login_username == read_user and login_password == read_pass:
        print('登录成功!')
        break
    else:
        ii = i + 1
        num = 3 - ii
        print('登录失败,请重新登录!您还剩余{}次数'.format(num))
else:
    print('账号已锁定!')
View Code

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python的常用语句 下一篇Python 官方文档解读(2):threadi..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目