简单的注册登录

username = input('请填写账号>>>')
password = input('请填写密码>>>')
with open('log',mode='w',encoding='utf-8') as f:
    # f.write('账号:' + username + '\n' +'密码:' + password)
    f.write('账号:{}\n密码:{}'.format(username,password))
print('注册成功!')
print('请输入账号密码')

count = 0
while count < 3:
    username = input('账号:')
    password = input('密码:')
    with open('log',mode='r+',encoding='utf-8') as f:
        li = f.readlines()
        # print(li[0][3:])
        # print(li[1][3:])
        count += 1
     #strip,默认可以去空格和换行符 if username == li[0][3:].strip() and password == li[1][3:].strip(): print('登录成功!') break elif count == 3: print('账号密码错误多次!终止输入') break else: print('账号或者密码错误!')

 

转载于:https://www.cnblogs.com/chengoudan/p/10411589.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值