for循环使用笔记
1.for i in rang(1,101,2) #2为步长
print("loop",i)
2.flag 标志位
3.for 循环
CODE1 for与else一起用:当for循环正常执行完循环时,则执行else语句;当for执行过程中有break后,则不执行else
_user ="wangbin"
_passwd = "123abc"
for i in range(3):
username = input("Username:")
password = input("Password")
if username == _user and password == _passwd:
print("Welcome %s login...." %_user)
break
else:
print("Invalid username or password!")
else:
print("错误次数太多,禁止登陆")
CODE2
_user ="wangbin"
_passwd = "123abc"
passed_authentication = False
for i in range(3):
username = input("Username:")
password = input("Password")
if username == _user and password == _passwd:
print("Welcome %s login...." %_user)
passed_authentication = True
break
else:
print("Invalid username or password!")
if not passed_authentication:
print("错误次数太多,禁止登陆")
数据驱动变革-云将skyell。用Flask+Nginx+uWsgi搭建的个人博客:http://www.skyell.cn/