json.decoder.JSONDecodeError:期望值:第1行第1列(char 0)Json错误

时间:2017-01-25 18:28:45

标签: python json python-3.x

        for i in os.listdir("./saves/"):
            path = './saves/' + i
            if path.endswith(".json"):
                with open(path, "r"):
                    config = json.loads(path)
                    ctime = config["Creation Time"]

好的,这是造成错误的小代码。我得到了一个json解码器错误这是回调

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 1550, in __call__
    return self.func(*args)
  File "/Users/acrobat/PycharmProjects/Jan9coderun/TranslatorVCS/Quiz.py", line 318, in saveGame
    config = json.loads(path)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

我的保存文件夹与我的代码位于同一工作目录中,并且有一个quiz.json,一个notes.txt和一个__init__.py文件。

0 个答案:

没有答案