小编Aim*_*mee的帖子

Enthought Canopy中的Python文件open()失败:"IOError No such file or directory"

我在Enthought Canopy下运行代码来打开并读取文件.它一直告诉我IOError.

但我很确定文本文件名是正确的,并且它与Python文件位于同一目录中,并且代码在其他IDE(如Python IDLE)中运行良好.不知道出了什么问题.有什么建议?

inFile = open('words.txt', 'r')
words = inFile.read().split()
Run Code Online (Sandbox Code Playgroud)

失败了 IOError: [Errno 2] No such file or directory: 'words.txt'

python file-io working-directory enthought canopy

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

canopy ×1

enthought ×1

file-io ×1

python ×1

working-directory ×1