为什么我的代码会给我一个“mystica.json not found”错误?

2024-09-30 04:37:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从json文件加载一些变量,但是找不到该文件

我试过删除文件并重新生成,重命名,移动文件,但都没有成功

def loadVar():
    with open('mystica.json') as read_file:
        variables = json.load(read_file)
        return variables

我希望它从mystica.json中获取值,但它给了我一个错误

FileNotFoundError: [Errno 2] No such file or directory: 'mystica.json'


Tags: 文件jsonreadreturndefas错误with

热门问题