def main():
while True:
welcome_login()
num1 = int(input('请选择1-3:'))
if num1 == 1:
register_login()
elif num1 == 2:
register()
else:
return
def welcome_login():
print('*** 欢迎来到XX管理系统 ***')
print('❤❤❤ 1. 登 录')
print('❤❤❤ 2. 注 册')
print('❤❤❤ 3. 退 出')
print('================================================')
def register_login():
with open('./stuinfo.txt', 'r', encoding='utf-8') as f:
users = eval(f.read())
user_name = (input('请输入3-6位数账号:'))
pw = input('输入密码:')
if user_name not in users:
print('登录失败!请先注册账号')
if pw not in users[user_name]:
print('登录失败,密码错误!')
return student_info
def register():
with open('./stuinfo.txt', 'r', encoding='utf-8') as f:
xxx = eval(f.read())
users = {}
user1 = input('输入3-6位注册账号:')
if user1 in xxx:
print('此账号已被注册!')
return
pw1 = input('输入账号密码:')
users[user1] = pw1
with open('./stuinfo.txt', 'w', encoding='utf-8') as f:
f.write(str(users))
def student_info():
with open('./stuinfo.txt', 'r', encoding='utf-8') as f:
xx2 = eval(f.read())
print('欢迎' + str(xx2))
day12-homework
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...