为什么我在读取 .json 文件时会收到此错误?
why am i getting this error when reading a .json file?
所以我有这个函数来读取 json 文件和 return 文件中的数据字典
def file_read(source):
with open(source) as file:
data = file.read()
dictionary = json.loads(data)
return dictionary
我正在使用的文件名为 'users.json' 并格式化为
{"Jim":("password", "MMA60V")}
然而,每当我尝试 运行 代码来读取 'users.json' 中的内容时,我都会收到此错误
json.decoder.JSONDecodeError: Expecting value: line 1 column 8 (char 7)```
does anyone know why this is happening and a possible solution thank you.
这是不正确的 JSON 并且由于您使用的是 json.loads
,您会收到错误消息。
将JSON粘贴到https://jsonlint.com/中,可以看到输入无效。 JSON 不支持元组。
所以我有这个函数来读取 json 文件和 return 文件中的数据字典
def file_read(source):
with open(source) as file:
data = file.read()
dictionary = json.loads(data)
return dictionary
我正在使用的文件名为 'users.json' 并格式化为
{"Jim":("password", "MMA60V")}
然而,每当我尝试 运行 代码来读取 'users.json' 中的内容时,我都会收到此错误
json.decoder.JSONDecodeError: Expecting value: line 1 column 8 (char 7)```
does anyone know why this is happening and a possible solution thank you.
这是不正确的 JSON 并且由于您使用的是 json.loads
,您会收到错误消息。
将JSON粘贴到https://jsonlint.com/中,可以看到输入无效。 JSON 不支持元组。