python写的http客户端测试程序


Python #http2012-11-23 00:03

直接上代码:

#httpclient.py

import http.client
with open("srv.file") as f:
	data = f.read()
conn = http.client.HTTPConnection("192.168.59.128:8099")
#注意encode函数,否则报错 http://yige.org
conn.request("POST", "sys.service.release.func", data.encode('utf-8'))
response = conn.getresponse()
data = response.read()
print(response.status, response.reason)
print('res:', data.decode('utf-8'))
conn.close()


相关文章

粤ICP备11097351号-1