Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)json错误_Python_Json_Python 3.x - Fatal编程技术网

Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)json错误

Python json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)json错误,python,json,python-3.x,Python,Json,Python 3.x,好的,这是导致错误的小代码。我得到一个json解码器错误,这里是回调 for i in os.listdir("./saves/"): path = './saves/' + i if path.endswith(".json"): with open(path, "r"): config = json.loads(path)

好的,这是导致错误的小代码。我得到一个json解码器错误,这里是回调

        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"]

“我的保存”文件夹与“我的代码”位于同一工作目录中,其中有一个
quick.json
、一个
notes.txt
、一个
\uuuu init\uuuuuuuuuuuuy.py
文件。

json文件是什么样子的?这可能是由无效或空的json文件引起的。噢。您可能希望open(path)为f:config=json.load(f)文件无效,我现在看到了。这也解决了我下一篇评论中的错误。它似乎在制作糟糕的json文件,我可能会为此发布另一个问题。我按照juanpa说的做了,但我得到了一个不同的错误,额外的日期:(行和列)
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)