2016-07-07 78 views

回答

1

你可以使用一個嘗試,除了while循環

#Inital user and passw need to be defined up here 
log=False 
while log==False: #to loop until a correct password is aqquired 
    try: 
     server.login(user, passw) #attempt to log into smtp server 
     log=True #sets to true if log in is successful 
    except: 
     print('Incorrect Username or Password:\n') 
     user=input('Enter new Username: ') #gets new username and password 
     passw=input('Enter new Password: ') 

內的用戶名和密碼提供反饋這應該只是遍歷,直到正確的用戶名或密碼被輸入, 然後它將登錄