【发布时间】:2021-02-18 13:43:36
【问题描述】:
file = open('python-ai-info.txt', 'r')
words = file.read()
file.close()
这是正确的吗?请帮我修复它。我想打开名为 python-ai-info.txt 的文件。我目前收到错误:
Traceback (most recent call last):
File "C:\Users\sgcoder1337\AppData\Local\Programs\Python\Python38-32\rhyme ai.py", line 1, in <module>
file = open('python-ai-info.txt', 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'python-ai-info.txt'
【问题讨论】:
-
这能回答你的问题吗? How to Open a file through python
-
Python 找不到文件。确保该文件与此脚本位于同一文件夹中。
标签: python python-3.x