我有一个名为" paintingJobs"的文本文件。数据如下所示:
E5341,21/09/2015,C102,440,E,0
E5342,21/09/2015,C103,290,A,290
E5343,21/09/2015,C104,730,N,0
E5344,22/09/2015,C105,180,A,180
我编写的程序只找到第一个条目,但找不到第一行以外的任何数据(我认为它是用Python做的,包括用户名前面的/ n)程序看起来像这样。
def ASearch():
print("Option A: Search for an estimate")
print("Please enter the estimate number: ")
estimateNumber = str(input())
file = open("paintingJobs.txt", "r")
paintJobs = file.readlines()
file.close()
length = len(paintJobs)
paintData = []
for line in paintJobs:
estNumber, estDate, CustID, FinalTotal, Status, AmountPaid = line.split(",")
if estimateNumber == estNumber:
print("Estimate number: ", estNumber)
print("Customer ID: ", CustID)
options()#this is a function in a for a different part of the program that works fine
else:
print("You have entered an incorrect estimate number; please try again")
ASearch()
如何让程序读取(并返回值)列表E.G中的第二个条目。 E5342(任何帮助将非常感激)