python - FileNotFoundError 即使文件存在
问题描述
因此,我正在使用 Python 3 和 Ursina 游戏引擎制作游戏,并在尝试加载文件时不断收到此错误:
Traceback (most recent call last):
File "main.py", line 5, in <module>
from src.menu import *
File "/home/mysteriousk/Desktop/moni moni moni/src/menu.py", line 4, in <module>
with open('../assets/database/database.json','r') as E:
FileNotFoundError: [Errno 2] No such file or directory: '../assets/database/database.json'
我正在执行的文件是main.py and the file I am importing is in the folder src and is named
menu.py`。加载我的文件的代码:
with open('../assets/database/database.json','r') as E:
stuffs = json.load(E)
该文件显然存在于目录 assets/database 中。请让我知道有什么问题,感谢您的帮助。
解决方案
推荐阅读
- r - rmarkdown::render 不起作用,但在编织时起作用
- zend-framework - 无法将服务“Zend\Db\Adapter\AdapterInterface”解析为工厂
- swift4 - 表视图没有填充数据,但我的打印语句正在工作
- asp.net - 在 IIS 中发布 Web 应用程序得到不同的错误
- python - 熊猫中两个日期列之间的比较
- angular - (window as any).global = window;
- wordpress - Wordpress 图像名称区分大小写给出 404 错误
- ios - ios + 带有麦克风的录音蓝牙设备(airpod)
- android - 使用 volley 获取 json 对象和数组
- javascript - 使用 toJSON() 访问对象的属性