---------------edit-in-windows-by-pycharm---------------------
import random
uname = "mologa"
psword = "mologa2016"
times = int(random.randint(0,2))
#dict = {uname:'mologa',psword:'mologa2016'}
while times < 3:
username = input("please you name:")
if username == uname:
while times < 3:
password = input("please enter your password:")
if password == psword:
print("welcome login!")
else:
key = input("do you want to try again!")
if key == 'yes' or key == 'y':
times += 1
continue
else:
# print("bye-bye!^_^")
pass
break
else:
print("user no exits")
key = input("do you want to chang again")
if key == 'yes' or key == 'y':
continue
else:
print("bye-bye!^_^")
break
if times >= 3:
print("sorry!user is locked.")
print(times
--------------------test-1------------------------
F:\Python35\python.exe F:/mologa-workspace/two.py
please you name:1231
user no exits
do you want to chang againy
please you name:wd23d2
user no exits
do you want to chang againy
please you name:12edd23d
user no exits
do you want to chang againy
please you name:df2qdf34f
user no exits
do you want to chang againy
please you name:mologa
please enter your password:f23d
do you want to try again!y
sorry!user is locked.
3
Process finished with exit code 0
--------------------test-2------------------------
F:\Python35\python.exe F:/mologa-workspace/two.py
please you name:mologa
please enter your password:df23r3
do you want to try again!y
please enter your password:d23dfa
do you want to try again!y
please enter your password:f23frawf
do you want to try again!y
sorry!user is locked.
3
Process finished with exit code 0
--------------------test-3------------------------
F:\Python35\python.exe F:/mologa-workspace/two.py
please you name:mologa
please enter your password:mologa2016
welcome login!
Process finished with exit code 0
谢谢!小组导师罗大帅给我提示了一个while循环内的参数pass,迈出了第一步,非常感谢!