python发送post数据
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()