为什么读取.json文件时出现此错误?

所以我有此功能来读取json文件并返回通过它的文件中数据的字典

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.
tangfeng1212 回答:为什么读取.json文件时出现此错误?

那是不正确的JSON,并且由于您使用的是json.loads,因此会出现错误。

将JSON粘贴到https://jsonlint.com/中,您会看到输入无效。 JSON不支持元组。

本文链接:https://www.f2er.com/2938789.html

大家都在问