登陆系统
import json
#写入文本
def write_text(file_name: str, results: str):
with open('files/users.json', 'a', encoding='utf-8') as f:
f.write(results)
return True
#读文本
def read_text(file_name: str):
with open('./files/users.json','r', encoding='utf-8') as f:
return f.read()
#注册
def register():
while True:
user_name = input('请输入账号(3~6位):')
if not 3 <= len(user_name) <= 6:
print('请重新输入!')
continue
else:
break
while True:
password = input('请输入密码(6~12):')
if not 6 <= len(password) <= 12:
print('密码错误!')
continue
else:
break
#登录
def login():
user_name = input('请输入账号(3~6):')
password = input('请输入密码(6~12):')
users = files_users.json('users.json')
if not user_name in users:
print('登录失败')
return
else:
print('登录成功!')