import http.client,urllib.parse
host = 'iflying.sinaapp.com' #主机域名
path = '/test.php' #资源名
params = urllib.parse.urlencode({ #要传送的数据
'username':'Tom',
'password':'123'
})
headers = {"Content-Type":"application/x-www-form-urlencoded","Accept":"text/plain"} #头信息
conn = http.client.HTTPConnection(host)
conn.request('POST',path,params,headers)
response = conn.getresponse()
print(response.read())
conn.close()
转载于:https://www.cnblogs.com/onestow/p/4333219.html