【解决】JSONDecodeError: Expecting property name enclosed in double quotes

读取json格式文件时报错:

    报错原因:最后一个 key : value 键值对后,多了一个逗号,相当于多了一个空的键值对,导致解析报错:

 with open("ccxt_config.json", 'rt') as f:
        config_info = json.load(f)

错误的文件内容如下:

{
  "rule":{
    "namespace":"strategy",
    "name":"test_exp_1496234234223400",
    "version":0,
    "last_modify_time":1434234236819000,
    "log_rate":1023300,
    "schema_version":"hello_world!"
  },
  "key":value,
}
 
 

正确的文件格式如下:

 
 
{
  "rule":{
    "namespace":"strategy",
    "name":"test_exp_1496234234223400",
    "version":0,
    "last_modify_time":1434234236819000,
    "log_rate":1023300,
    "schema_version":"hello_world!"
  },
  "key":value
}


猜你喜欢

转载自blog.csdn.net/wjunsing/article/details/80025038