i=input('num(0 or 1):') #0:未注册, 1:已注册 m = input('name:') n = input('code:') if i == 0: try: p=open('files/students23.txt','rt',encoding='utf-8') except FileNotFoundError: all_student = [] else: all_student = eval(p.read()) for x in eval(p.read()): if x.key() == m: print('账户名已注册') p.close() break else: k = {'m': n} all_student.append(k) p.close() f = open('files/students23.txt', 'w', encoding='utf-8') f.write(str(all_student)) f.close() print('注册成功') else: f=open('files/students23.txt','rt',encoding='utf-8') r=f.read() for x in eval(r): if x.key() == m and x.value() == n: print('登陆成功') break else: print('登陆不成功')
day14hw
最新推荐文章于 2024-08-19 16:01:20 发布