python3 HTTP post

import json
import urllib
import urllib.request
newConditions = {"jsonrpc":"2.0", "id":1, "method":"eth_getBlockByNumber", "params":["pending",False]}
params = json.dumps(newConditions).encode('utf8')
req = urllib.request.Request("http://****:***", params,
                             {'content-type': 'application/json'})
response = urllib.request.urlopen(req)
print(response.read().decode('utf8'))

print('----end-----')
相關文章
相關標籤/搜索