python写的http客户端测试程序,不到10行代码,简洁高效,直接上源码。
#httpclient.py
import http.client
with open("srv.file") as f:
data = f.read()
conn = http.client.HTTPConnection("192.168.59.128:8099")
#注意encode函数,否则报错
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()
阅读(4517) | 评论(0) | 转发(0) |