使用者互動程式

2022-08-23 05:09:12 字數 1102 閱讀 3438

flog = true   #退出多重迴圈使用

count = 0

while count < 3:

_username = input('使用者名稱:')

_password = input('密碼:')

f1 = open(file='資訊.txt',mode='r',encoding='utf-8')

for line1 in f1:

line1 = (line1.split())

username1 = line1[0]

if _username in username1:

flog = false

print('該使用者已被鎖定,無法登陸!!')

break#如果上述條件成立,則for迴圈退出

f1.close()

if not flog:

break #如果上述條件成立,則while迴圈退出

f = open(file='使用者資訊.txt',mode='r',encoding='utf-8')

for line in f:

line = (line.split())

username = line[0]

password = line[1]

if _username == username and _password == password:

flog = false

print('登陸成功!\n歡迎%s登陸'%(_username))

break #如果上述條件成立,則for迴圈退出

f.close()

if not flog: #如果上述條件成立,則while迴圈退出

break

else:

print('使用者名稱或密碼錯誤!!')

count += 1

if count == 3:

f1 = open(file='資訊.txt',mode='a+',encoding='utf-8')

f1.write('%s\t%s\n'%(_username,_password))

f1.close()

else:

exit()

三 python 使用者互動程式

一 使用者輸入 input 輸出輸入一 s 字串 d 整型 f 字元型,小數 變數1,變數2.info1 info1 of s name s age d job s salary s name,name,age,job,salary print info1 輸入輸出二 format name age...

Python入門學習 使用者互動程式

author winnie hu username input username password input password print username,password raw input 2.x input 3.x 字串拼接法 name input name age input age j...

Python 使用者互動程式 day1

變 變化,重在變字,量 計量,衡量,表示一種狀態 變數賦值 number 1 變數的規則 數字,字母,下劃線,任意組合,數字不能開頭,python 的關鍵字不能用,變數名盡量有意義。變數表示的某種意義 禁止使用的python變數名 and as assert break class continue...