the*_*man 8 python directory file
我正在编写一个 python 脚本,我需要在其中打开一个“.txt”文件夹并分析其中的文本。
我已将此“.txt”文档保存在与 Python 脚本相同的文件夹中。
但是,当我去打开文件时;file = open("words.txt",'r')
file = open("words.txt",'r')
我收到错误:No such file or directory: 'words.txt'。
No such file or directory: 'words.txt'
我不明白为什么会发生这种情况?
小智 9
可能是因为您当前的工作目录与存储文件的目录不同。尝试提供文件的完整路径
file = open("<full_path>\words.txt",'r')
归档时间:
6 年 前
查看次数:
34851 次
最近记录: