python写的http客户端测试程序


Python #http2012-11-23 00:03

直接上代码:

01#httpclient.py
02 
03import http.client
04with open("srv.file") as f:
05    data = f.read()
06conn = http.client.HTTPConnection("192.168.59.128:8099")
07#注意encode函数,否则报错 http://yige.org
08conn.request("POST", "sys.service.release.func", data.encode('utf-8'))
09response = conn.getresponse()
10data = response.read()
11print(response.status, response.reason)
12print('res:', data.decode('utf-8'))
13conn.close()


相关文章

粤ICP备11097351号-1