day8.登陆注册简单实现
1 username = input('请输入注册的用户名:') 2 password = input('请输入注册名的密码:') 3 with open('list_of_info',mode='w',encoding= 'utf-8') as f: 4 f.write('{}\n{}'.format(username,password)) 5 print('注册成功') 6 7 8 lis = [] 9 i = 0 10 while i < 3: 11 usn = input('请输入用户名:') 12 pwd = input('请输入密码:') 13 with open('list_of_info', mode='r+', encoding='utf-8') as f1: 14 for line in f1: 15 lis.append(line.strip()) 16 if usn == lis[0] and pwd == lis[1]: 17 print('登陆成功') 18 break 19 else: 20 print('账号密码错误') 21 i = i + 1