|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- print("|———新建用户:N/n———|")
- print("|———登陆账号:E/e———|")
- print("|———退出程序:Q/q———|")
- temp=input("|———请输入指令代码:")
- dict1={}
- def foo(temp):
- if temp=='N' or temp=='n':
- name1=input("请输入用户名:")
- secret1=input("请输入密码:")
- while True:
- if name1 not in dict1.keys():
- dict1[name1]=secret1
- print("注册成功,赶紧试试登陆吧~~~")
- break
- else:
- name1=input("此用户名已经被使用,请重新输入:")
- secret1=input("请输入密码:")
- if temp=="E" or temp =="e":
- name2=input("请输入用户名:")
- i = 2
- r = 2
- while i>0:
- if name2 in dict1.keys():
- secret2=input("请输入您的密码")
- while secret2!=dict1[name2] and r>0:
- secret2=input("您输入的密码有误,请重新输入:")
- r-=1
- if secret2==dict1[name2]:
- print("Successful!")
- break
- else:
- print("————————————————————————————————")
- name2=input("您输入的用户名不存在请重新输入:")
- i -= 1
- while temp=="Q" or temp=="q":
- print("感谢使用本程序,再见!")
- break
- foo(temp)
- while temp!="Q" and temp!="q":
- print("————————————————————————————————")
- temp=input("|———请输入指令代码:")
- foo(temp)
复制代码
如下,一路回车注册完成,再一路回车登录成功:
- Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
- Type "copyright", "credits" or "license()" for more information.
- >>>
- ======================= RESTART: D:/Desktop/kjmknjk.py =======================
- |———新建用户:N/n———|
- |———登陆账号:E/e———|
- |———退出程序:Q/q———|
- |———请输入指令代码:n
- 请输入用户名:
- 请输入密码:
- 注册成功,赶紧试试登陆吧~~~
- ————————————————————————————————
- |———请输入指令代码:e
- 请输入用户名:
- 请输入您的密码
- Successful!
- ————————————————————————————————
- |———请输入指令代码:
复制代码
永远不要相信你的用户,把他们想象成黑客或者是熊孩子,这样你的程序自然会更加安全和稳定。
|
|