ValueError:无法在python脚本中解码JSON对象

时间:2018-08-11 21:47:12

标签: python json

import json    
import requests    
import pprint    
from datetime import datetime    
url = 'url'    
cursor = context.cursor()   
cursor.execute('SELECT * from table')    
for a in cursor.fetchall():     
  urlpost = url + '/'+'Id'+'/data'     
  data = { "Id": str(a[0]),     
      "Name": "null",     
      "Type": str(a[4])    
  }    
  data_json = json.dumps(data)     
  headers = {'Content-type': 'application/json'}     
  response = requests.post(urlpost, data=data_json, headers=headers)    
  pprint.pprint(response.json())

我试图将表中的数据放入API。但是出现错误“值错误:无法解码JSON对象”。我不知道缺少什么!

0 个答案:

没有答案