我有这个主要的功能,在里面我有一个我定义为:
的removeHeaderdef removeHeader (file_name):
f = open(file_name).readlines()
firstLine = f.pop(6)
return firstLine
主要功能:
def readTasksFile(file_name):
"""Reads a file with a list of translation tasks into a collection.
"""
inFile = removeHeader(open(file_name, "r"))
tasksList = []
for line in inFile:
taskData = line.rstrip().split(", ")
tasksList.append(taskData)
return tasksList
问题是,它找不到我的文件加上我非常确定removeHeader缺少一些东西,我已经看过一些关于删除已经在这里被问过的行的问题但是我没有&# 39;我真的很了解他们中的大多数人,因为现在大学新生我编程非常糟糕
答案 0 :(得分:0)
In your removeHeader
method you're trying open a file, but while calling the method removeHeader
you're already passing the file handler.
Replacing inFile = removeHeader(open(file_name, "r"))
with
inFile = removeHeader(file_name)
in your readTasksFile
should work