我确认" apples.txt"存在。我的代码有什么问题?
def Loadfile(fileName):
myfile=open(fileName,'r')
next(myfile)
for line in myfile:
linesplit=line.split()
print line
print Loadfile('apples.txt')
答案 0 :(得分:3)
该文件可能不在您的working directory中。将工作目录更改为apples.txt
所在的位置,或提供文件的完整路径,例如'C:\\folder\\subfolder\\apples.txt'
答案 1 :(得分:0)
arq = open('C:\\python2.6\\projetos\\test\\list.txt', 'r')
texto = arq.readlines()
for linha in texto:
print(linha)
arq.close()