我正在尝试用python编写一段代码,将 JSON 文件从文件夹导入到我的程序中,以便它访问内部的数据。但是,我面临错误 global bees with open('data/bees.json') as f: bees = json.load(f)["bees"]在data/bees.json我有这个: { "bees": [] }我得到的错误Traceback (most recent call last): File "d:/Entertainment/Coding/Python/Pygame/BUG WORLD/main.py", line 70, in <module> bees = json.load(f) File "C:\Users\ernes\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 296, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "C:\Users\ernes\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 348, in loads return _default_decoder.decode(s) File "C:\Users\ernes\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\ernes\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from Nonejson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)有没有一种方法可以从另一个文件夹导入 JSON 文件而不会导致任何错误?请帮忙
添加回答
举报
0/150
提交
取消