_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("滾啊!")
?