所以首先,這不是完整的程式。我正在開發一個銀行管理系統,剛剛遇到了這個問題。我試圖讓客戶輸入他們的登錄 ID 和密碼,然后它檢查第一個檔案,然后代碼將打開另一個檔案,檢查第一個元素與登錄 ID 相同,然后列印出客戶帳戶型別和余額. 文本檔案示例在底部,我不知道為什么我的代碼通過第一個回圈而不是第二個回圈。
def LCustomerAccount():
EnteredID = str(input("========== Please Type in Your Account ID:"))
EnteredPassword = str(input("========== Please Type in Your Password:"))
B = open("Customerlogin.txt", "r")
G = open("system.txt", "a ")
Account_NumberList = []
for line in B.readlines():
id, pw = line.strip().split("|", 1)
if (EnteredID == id) and (EnteredPassword == pw):
print("========== Login Successfull============")
print("========== Welcome User============")
Account_NumberList.append(EnteredID)
B.close()
break
else:
print("Wrong Account Number/password")
menu()
for line in G.readlines():
idc,at,balance= line.strip().split("|",2)
if (idc == Account_NumberList):
print("Your Account Type:", at)
print("Your Account Balance:",balance)
print("========== (Option 1). Deposit an amount from your account ============")
print("========== (Option 2). Withdraw an amount from your account============")
print("========== (Option 3). Change Your Account Password ============")
print("========== (Option 4). Log Out ============")
EnterOption = int(input("==========Please Enter Your Option"))
客戶登錄.txt
020403100865|3088
系統檔案
020403100865|儲蓄|1000|李|3088|00001|200
uj5u.com熱心網友回復:
我認為如果不修改txt檔案就足夠了:
G = open("system.txt", "r")
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/376171.html
上一篇:為什么我的函式對除了塊不起作用?
