_user= "yangtuo" _passwd = "123456"# passd_authentication = False #flag 标志位for i in range(3): #for 语句后面可以跟else,但是不能跟elifusername = input("Username:")password = input("Password:")if username == _user and password == _passwd :print("Welcome %s login ..." %_user)# passd_authentication = Truebreak #跳出,中断,若此行被执行,则不会执行后面的else语句else:print("Invalid username or password !") else: #只要上面的for循环正常循环完毕,就会执行else语句 # if not passd_authentication:print("滚啊!")