为什么我的代码要经过第一个for循环而不经过第二个for循环



因此,要启动此程序,这不是完整的程序。我正在研究一个银行管理系统,刚刚遇到了这个问题。我试图让客户键入他们的登录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

System.txt

020403100865|节省|1000|Lee |3088|00001|200

如果您不想修改txt文件,我认为这就足够了:

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

最新更新