1. 程式人生 > >python日記,簡單的密碼登錄

python日記,簡單的密碼登錄

write word bre txt 簡單的 break for lines .com

# readme:
#     blogger address:www.cnblogs.com/ne-zha
#     ne_zha
#     要求:
#     編寫登陸接口
#     1.輸入用戶名密碼
#     2.登錄成功顯示歡迎信息
#     3.輸錯三次鎖定


lock_file=open(file_lock.txt,r)
user_pass=open(username_file.txt,r)

cmd =int(input(‘‘‘
登錄系統輸入1
退出系統輸入2
請輸入操作:
 ‘‘‘))
if cmd ==2:
    exit()
elif cmd 
==1: username = input("please input your user...") for i in range(3): for i in lock_file.readlines(): i = i.split() if username in i[0]: print(對不起 %s 已鎖定 % username) exit() match = False for j in user_pass.readlines(): user,passwd
=j.split() if username ==user: password =input("please input the passwd") if password ==passwd: print("登錄成功!") match = True break elif password !=passwd: for n in range(2): password
=input("密碼錯誤,請重新輸入!") if password ==passwd: print("登錄成功!") match = True break if username !=user: print("用戶名不存在!") exit() if match ==False: print("三次輸入錯誤,賬戶以被鎖定!") lock_file.write(%s \n % username) lock_file.close() user_pass.close() exit()

python日記,簡單的密碼登錄