def registered():
user_account = input("请输入注册的账号:")
user_password = input("请输入该账号的密码:")
repassword = input("确认账号密码::")
length = len(user_account)
if user_password == repassword:
with open('users_data.txt', 'a+',encoding='utf-8') as file:
file.seek(0,0)
answer = file.read().split('\n')
for i in answer:
if user_account not in i[:length]:
continue
else:
print("此账号已被使用!")
break
else:
input_user = '{} {}\n'.format(user_account, user_password)
file.write(input_user)
print("注册成功")
else:
print("密码错误")
judge = 'Y'
while judge == 'Y':
registered()
judge = input('是否要继续注册账号(输入Y继续注册)?')