【发布时间】:2023-08-09 13:40:01
【问题描述】:
我现在开始学习 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 终端中打开也是如此!
非常感谢!!
【问题讨论】:
-
+1 使用 Komodo,我最喜欢的 Python 编辑器!
标签: python macos komodoedit