from urllib import request
headers={"Cookie": "JSESSIONID=EC09D23D8FD081387CA797C9D1EB0B77",
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"User-Agent": "Dalvik/1.6.0 (Linux; U; Android 4.4.4; MI 2A MIUI/6.3.31)",
"Host": "www.xiaodouzhuan.cn",
"Connection": "Keep-Alive",
"Content-Length": "774"
}
data='data=test'
url="http://www.test.conf"
data=data.encode() #将str字符串转为bytes类型
url = request.Request(url,headers=headers,data=data) #封装请求
html = request.urlopen(url).read() #提交请求
html = html.decode(encoding="utf-8") #转码