JSONDecodeError:期望属性名称用双引号引起来:第2行第6列(字符6)

时间:2019-09-03 09:27:32

标签: python json

在执行以下python代码时出错:

import json
json_str = """
  {
  “AircraftKey”: “AircraftKey_data”,
  “Latitude”: 100,
  “Longitude”: 200,
  “FuelQuantityLeft”: “FuelQuantityLeft_data”,
  “FuelQuantityRight”: “FuelQuantityRight_data”,
  “TKSLeft”: “TKSLeft_data”,
  “TKSRight”: “TKSRight_data”,
  “OxygenQuantity”: “OxygenQuantity_data”,
  “OilTemperature”: “OilTemperature_data”,
  “Battery1Voltage”: “Battery1Voltage_data”,
  “Battery2Voltage”: “Battery2Voltage_data”,
  “ReceivedDate”: 20190901,
  “LastUpdatedDate”: 20190901
   }"""
data = json.loads(json_str)

1 个答案:

答案 0 :(得分:0)

json.loads之前添加以下行:

json_str = json_str.replace('“', '"').replace('”', '"')