gpt4 book ai didi

python - IO错误: Errno 2 No such file or directory python

转载 作者:行者123 更新时间:2023-11-30 23:13:08 25 4
gpt4 key购买 nike

我已经确认“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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com