簡體   English   中英

為什么我的代碼 go 通過第一個 for 循環而不是第二個 for 循環?

[英]Why does my code go through the first for loop but not the second for loop?

所以要開始這個,這不是完整的程序。 我正在研究銀行管理系統,但遇到了這個問題。 我試圖讓客戶輸入他們的登錄 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

系統.txt

020403100865|儲蓄|1000|李|3088|00001|200

我認為如果您不修改txt文件就足夠了:

G = open("system.txt", "r")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM