我现在开始学习 Python,所以我的问题有点愚蠢
我有这段代码
#!/usr/local/bin/python3
# encoding: utf-8
fh = open("lines.txt")
for lines in readlines():
print(lines)
文本文件lines.txt 退出,它在我的页面的同一目录中,我使用Komodo Edit,当我运行文件时,出现此错误。
Traceback (most recent call last):
File "/Users/Jeff/Sites/PythonLearning/forloop.py", line 4, in <module>
fh = open("lines.txt")
IOError: [Errno 2] No such file or directory: 'lines.txt'
有趣的是,如果我在 IDLE 中打开这个文件,它工作得很好,如果我在 Mac os X 终端中打开也是如此!
非常感谢!!