我正在嘗試用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
提交
取消