open(txt_path, "r") as f
时间: 2024-04-24 13:27:53 浏览: 38
TXT_test.rar_test.txt文_监控文件夹_监控文件夹下的文件生成
回答: 在打开文件时,出现了FileNotFoundError错误,错误信息为\[3\]。这个错误是由于文件路径不正确导致的。根据错误信息,文件路径应该是'G:\anaconda\pythonProject2\HWDB1/train.txt',但实际上文件路径应该是'G:\anaconda\pythonProject2\DATA\HWDB1/train.txt'。所以,只需要将文件夹HWDB1改名为DATA,使路径名为'G:\anaconda\pythonProject2\DATA\HWDB1/train.txt'即可解决这个问题。
#### 引用[.reference_title]
- *1* *2* [解决Python模块报错:with open(file_path,‘wb‘,encoding=‘utf-8‘) as f: ValueError: binary mode ...](https://blog.csdn.net/weixin_44898291/article/details/121354433)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:](https://blog.csdn.net/woshicaiji12138/article/details/124309820)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文