import re
username=[]
password=[]defmain():print("---------------主界面---------------")defget_choice():print('''
1.用户注册
2.用户登录
3.退出
------------------------------------''')returnint(input("请输入你的选择序号:"))defcheck_password(pwd):
res = re.search("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{6,20}$", pwd)returnTrueif res elseFalsedefregister():
ua =input("请输入你的用户名:")
pw =input("请输入你的密码:")whileTrue:if check_password(pw):print("注册成功")breakelse:print("密码格式不正确请重新输入!")
pw =input("请输入你的密码:")
username.append(ua)
password.append(pw)deflogin():
ua =input("请输入你的用户名:")
pw =input("请输入你的登录密码:")for(a,b)inzip(username,password):if a == ua and b == pw:print("恭喜你登录成功!")breakelse:
pw =input("密码输入错误,请重新输入:")defexit_menu():return1
i =0while i ==0:
main()
choice = get_choice()if choice ==1:
register()elif choice ==2:print(username,password)
login()elif choice ==3:
i = exit_menu()