json.decoder.JSONDecodeError:期望值:,json.decoder.JSONDecodeError:期望属性名称用双引号引起来: [英] json.decoder.JSONDecodeError: Expecting value: , json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:

查看:106
本文介绍了json.decoder.JSONDecodeError:期望值:,json.decoder.JSONDecodeError:期望属性名称用双引号引起来:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python在我的文件中使用JSON:

Hi I am working with JSON in my file in Python:

import json
userData = '''[
{
    "userID" : "20",
    "devices" : {
        "360020000147343433313337" : "V33_03",
        "3f0026001747343438323536" : "Door_03",
        "170035001247343438323536" : "IR_06",
        "28004c000651353530373132" : "BED_17"
    }
},

]'''

info = json.loads(userData)

加载时出现此错误: json.decoder.JSONDecodeError:预期值:

I get this error when I load it: json.decoder.JSONDecodeError: Expecting value:

,或者有时当我添加一些内容时: json.decoder.JSONDecodeError:期望属性名称用双引号引起来:

or sometimes when I add something: json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:

推荐答案

尝试使用ast模块

例如:

import ast
userData = '''[
{
    "userID" : "20",
    "devices" : {
        "360020000147343433313337" : "V33_03",
        "3f0026001747343438323536" : "Door_03",
        "170035001247343438323536" : "IR_06",
        "28004c000651353530373132" : "BED_17"
    }
},
]'''

info = ast.literal_eval(userData)
print(info)

这篇关于json.decoder.JSONDecodeError:期望值:,json.decoder.JSONDecodeError:期望属性名称用双引号引起来:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆