![](/img/trans.png)
[英]How do I run my Python script? Why does the command line tell me "no such file or directory"?
[英]Why does python 3 tell me that there is no such file or directory when I use test.json in my code
我正在和我的朋友制作一個列表應用程序。 當我嘗試運行代碼時,會出現以下錯誤:
Traceback (most recent call last):
File "C:\Users\ellio_6\Desktop\Coding\Python\Programs\To-Do App\TeaTasksFuncs.py", line 75, in <module>
TaskManager()()
File "C:\Users\ellio_6\Desktop\Coding\Python\Programs\To-Do App\TeaTasksFuncs.py", line 6, in __init__
self.tasks, self.task_number = self.read_data("test.json")
File "C:\Users\ellio_6\Desktop\Coding\Python\Programs\To-Do App\TeaTasksFuncs.py", line 60, in read_data
with open(file_path,"r+") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'test.json'
請確保您運行代碼的文件與 test.json 文件位於同一文件夾中。 否則,給它一個文件的完整路徑。
我不得不檢查一個不同的文件,它是該程序的一部分,我忘記在另一個文件的 python 代碼中創建文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.