Python-注册
import time users = {} time = time.strftime('%Y-%m-%d %H:%M:%S') with open('user.txt')as fr: for line in fr: if line.strip(): user,password = line.split(',') users[user] = password while True: username = input('请输入账号:').strip() password = input('请输入密码:').strip() cwd = input('请再次输入密码:').strip() if username=='' and password=='' and cwd=='': print('不能为空') continue elif username in users: print('账户已存在') continue elif password != cwd: print('两次密码输入不一致') continue elif len(password)<6 or len(password)>13: print('密码长度需要是大于6位小于13位') continue else: users[username] = password print('%s注册成功,今天的时间是%s'%(username,time)) break with open('user.txt','a+')as fw: for i in users: p = ('%s,%s\n'%(i,users.get(i))) fw.writelines(p)
本文来自博客园,作者:他还在坚持嘛,转载请注明原文链接:他还在坚持嘛 https://www.cnblogs.com/brf-test/p/12588346.html