模擬使用者登入含註冊 python第8天

2022-08-31 21:15:16 字數 2179 閱讀 4306

print('

歡迎登入尚雅夢想python學習系統

'.center(30))

print('

******

' * 8)

flag =true

while

flag:

order = input('''

按'r'或者'r'進行使用者註冊\n按'l'或者'l'進行使用者登入

''')

if order.upper() == 'r'

: flag =true

while

flag:

username = input('

請輸入您要註冊的使用者名稱:')

line = open('

使用者資訊

', mode='

r+', encoding='

utf-8')

info =line.read()

info = info.split('\n'

) dic_info ={}

for index, item in

enumerate(info):

if index % 2 ==0:

dic_info[item] = info[index + 1]

line.close()

if username not

indic_info.keys():

password = input('

請輸入您的密碼:')

line = open('

使用者資訊

', mode='

r+', encoding='

utf-8')

line.read()

line.write(

'{}\n{}\n

'.format(username, password))

line.close()

break

else

:

print('

您輸入的使用者名稱已存在')

continue

if order.upper() == 'l'

: count = 3

while count >0:

line = open('

使用者資訊

', mode='

r+', encoding='

utf-8')

info =line.read()

info = info.split('\n'

) dic_info ={}

for index, item in

enumerate(info):

if index % 2 ==0:

dic_info[item] = info[index + 1]

line.close()

id = input('

請輸入您的使用者名稱:')

if id in

dic_info.keys():

psw = input('

請輸入您的密碼:')

if psw ==dic_info[id]:

print('

登入成功,請稍後...\n歡迎{}進入python學習系統

'.format(id))

flag =false

break

else

: count -= 1

if count ==0:

print('

密碼錯誤三次,正在退出...')

flag =false

break

print('

您的密碼錯誤,您還有{}次機會請重新輸入:

'.format(count))

else

: count -= 1

if count ==0:

print('

使用者名稱輸入錯誤三次,正在退出...')

flag =false

break

print('

您的使用者名稱輸入錯誤,您還有{}次機會請重新輸入:

'.format(count))

模擬使用者登入公升級版,包括使用者註冊資訊儲存,以及登入時調取匹配

python模擬註冊登入 python實現模擬登入

python實現模擬登入 2012 08 02 10 20 42 我來說兩句 當你要模擬登入乙個 時,首先要搞清楚 的登入處理細節 發了什麼樣的資料,給誰發等.我是通過httpfox來抓取http資料報來分析該 的登入流程。同時,我們還要分析抓到的post包的資料結構和header,要根據提交的資料...

python使用者註冊登入登出功能

root kl bin python3 author kl 使用者註冊登入登出功能 import getpass userdb 定義字典 defregister 定義註冊模組 uname input username strip strip兩邊去空格 if uname and uname not i...

模擬使用者登入

這裡有乙個儲存使用者賬戶資訊的字典,請用程式模擬系統的登入驗證過程。請用程式實現 用鍵盤模擬使用者輸入,判斷輸入的使用者名稱或密碼是否正確,並輸出登入資訊。如果輸入的使用者名稱存在,且密碼正確,則輸出success 如果輸入的使用者名稱存在,但密碼不正確,則輸出password error 如果輸入...