我已经确认“apples.txt”确实存在。我的代码有什么问题吗?
def Loadfile(fileName):
myfile=open(fileName,'r')
next(myfile)
for line in myfile:
linesplit=line.split()
print line
print Loadfile('apples.txt')
最佳答案
该文件可能不在您的 working directory 中。将工作目录更改为 apples.txt
所在位置,或提供文件的完整路径,例如 'C:\\folder\\subfolder\\apples.txt'
关于python - IO错误: Errno 2 No such file or directory python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29493444/