我如何计算从python中另一个文件读取的行数?

问题描述 投票:-2回答:1

我写了一个程序来确定学生编号是否有效。这些数字存储在单独的文件中,并且有+-43行学生编号。我的程序无法计算到该数字,并且输出的结果是读取了0行。

我认为该代码有问题:

rawdata=[]
print("Number of lines read: ",AnalyseStudent(rawdata))
numberofstudents=read(rawdata)
for student in rawdata:
    write(student,AnalyseStudent(student))
print("--> See output files for more detail")

Here is where you can see the problem

python count counter
1个回答
0
投票
rawdata=[]
count=read(rawdata)
print("Number of lines read: "+str(count))
for x in range(0,count):
    write(rawdata[x],AnalyseStudent(rawdata[x]))
print("--> See output files for more detail")
© www.soinside.com 2019 - 2024. All rights reserved.