1 #__author: hlc 2 #date: 2019/5/25 3 4 # for i in range(1,100,2) : #2为步长 5 # print("loop:",i) 6 7 # for i in range(100) : 8 # if i < 20 or i > 80 : 9 # print(i) 10 # 11 # _user = "abc" 12 # _passwd = "123" 13 # 14 # flag = False 15 # for i in range(3) : 16 # username = input("your usernaem>>>: ") 17 # password = input("your password>>>: ") 18 # if username == _user and password == _passwd : 19 # print("Welcome %s login ..." % _user) 20 # flag = True 21 # break #跳出 ,中断 22 # else: 23 # print("Invalid username or password !") 24 # if not flag : 25 # print("错误次数过多!。。。") 26 # 27 # C:\python37\python.exe D:/python-note/for_loop.py 28 # your usernaem>>>: sdaf 29 # your password>>>: asdf 30 # Invalid username or password ! 31 # your usernaem>>>: abc 32 # your password>>>: 123 33 # Welcome abc login ... 34 35 # C:\python37\python.exe D:/python-note/for_loop.py 36 # your usernaem>>>: a 37 # your password>>>: a 38 # Invalid username or password ! 39 # your usernaem>>>: a 40 # your password>>>: a 41 # Invalid username or password ! 42 # your usernaem>>>: a 43 # your password>>>: a 44 # Invalid username or password ! 45 # 错误次数过多!。。。 46 47 _user = "abc" 48 _passwd = "123" 49 50 for i in range(3) : 51 username = input("your usernaem>>>: ") 52 password = input("your password>>>: ") 53 if username == _user and password == _passwd : 54 print("Welcome %s login ..." % _user) 55 break #跳出 ,中断 56 else: 57 print("Invalid username or password !") 58 else: 59 print("错误次数过多!。。。") 60 61 # C:\python37\python.exe D:/python-note/for_loop.py 62 # your usernaem>>>: sdf 63 # your password>>>: sadf 64 # Invalid username or password ! 65 # your usernaem>>>: asdf 66 # your password>>>: asdf 67 # Invalid username or password ! 68 # your usernaem>>>: asdf 69 # your password>>>: asdf 70 # Invalid username or password ! 71 # 错误次数过多!。。。
原文地址:https://www.cnblogs.com/hlc-123/p/10923472.html
时间: 2024-11-09 05:56:55