<每日一題>題目1:簡單的註冊和登錄1.0
阿新 • • 發佈:2018-09-09
要去 換行符 去掉 utf-8 orm clas class app 成功
#版本1.0,最基本的註冊登錄
‘‘‘
1.註冊,將賬號和密碼分別寫在不同的文檔裏面
2.登錄,分別從賬戶文檔和密碼文檔進行讀取並登錄
‘‘‘
1 #註冊 2 Identity = input("請輸入您想要註冊的賬號:") 3 Password = input("請輸入您想要註冊的密碼:") 4 print("恭喜您註冊成功") 5 with open(‘id_ZC‘,mode=‘w‘,encoding=‘utf-8‘) as f1,open(‘pw_ZC‘,mode=‘w‘,encoding=‘utf-8‘) as f2: 6 f1.write(‘{}\n‘.format(Identity))7 f2.write(‘{}\n‘.format(Password))
1 #登錄 2 i = 0 3 ID = [] 4 PW = [] 5 while i < 1: 6 user_id = input("請輸入您的賬號:") 7 user_pw = input("請輸入您的密碼:") 8 with open(‘id_ZC‘,mode=‘r+‘,encoding=‘utf-8‘) as f1,open(‘pw_ZC‘,mode=‘r+‘,encoding=‘utf-8‘) as f2: 9 for line in f1:10 ID.append(line) 11 #print(ID) 12 for line in f2: 13 PW.append(line) 14 #print(PW) 15 #print(ID[0].strip() == ID[0]) #ID[0]後面有換行符需要去掉 16 17 if user_id == ID[0].strip() and user_pw == PW[0].strip(): 18 print("恭喜您登錄成功!") 19 else:print("對不起,登錄失敗!") 20 i+=1
<每日一題>題目1:簡單的註冊和登錄1.0