python3 发送gzip文件请求

#condig=utf-8
import requests
import json,gzip

def toGzipFormat(postData):
data=bytes(json.dumps(postData),'utf-8')
ct=gzip.compress(data,)
return ct

postData= {
"ProtocolType": "01003",
"TaskId": "1"
}

requestHeaders = {
'Content-Encoding': 'gzip',
'Content-Type':'x-application/x-gzip'
}

requests.post(url = 'XXXX',data=toGzipFormat(postData),headers=requestHeaders)

上一篇:Android应用程序资源的编译和打包过程分析


下一篇:js的严格模式