python day1-做業

readme:get

輸入用戶名和密碼,並進行判斷:若是輸入正確,提示成功登陸;若是不正確,提示錯誤用戶名和密碼。input

coding:import

import getpass登錄

_username = 'john'
_passwd = '123'
user = input("please enter your name:")
passwd = input("please enter your password:")
if user == _username and passwd == _passwd:
print("welcome user %s login!"% user)
else:
print("you entered wrong username or password!")


超過3次,提示鎖定用戶

coding:

import getpass
count = 0_username = 'john'_passwd = '123'while count <3:    user = input("please enter your name:")    passwd = input("please enter your password:")    if user == _username and passwd == _passwd:        print("welcome user %s login!"% user)    else:        print("you entered wrong username or password!")    count +=1print("your username now locked!")
相關文章
相關標籤/搜索