Python_Post方式提交json字符串

Python_Post方式提交json字符串

Zilin 2018.3.20

import urllib2
import json

data = {"query":{"match":{"imtype":"LTCUS"}},"sort":[{"rtdatetime":{"order":"desc"}}],"size":3}

headers = {'Content-Type':'application/json'}
request = urllib2.Request(url='http://159.138.1.196:9200/gspoc/idealmoney_rt_result/_search',headers=headers,data=json.dumps(data))
response = urllib2.urlopen(request)

print response.read()

猜你喜欢

转载自blog.csdn.net/qq_36023564/article/details/79622610