Python 技术篇-httpClient库连接服务器发送请求解析响应实例演示,No module named ‘httplib‘问题解决方法

新的 python 已经由 httplib 包变成了 http.client
所以如果还引入 httplib 库就会报错:ModuleNotFoundErr端口号是什么意思or: No modhtml5ule named 'httplib'

import http.client
httpClient = http.client.HTTPConnection('10.10.xx.xx',5554)
# 发送请求,直接用参数/,相当于直接访问ip+端口号
httpClient.request('GET','/')
# 获取请求
response = httpClient.getresponse()
# 分解response回应消息
print("status:"+str(response.status))
# print(response.reason)
# print(response.read())
print('-'*5+'Headers'+'-'*5)
print(response.getheaders())
print('-'*5+'Message'+'-'*5)
print(response.msg)

执行系统运维工资一般多少代码后结果系统运维包括哪些内容如下:

status:200
-----Headers-----
[('Accept-Ranges', 'bytes'), ('ETag', 'W/"93-1589209308000"'), ('Last-Modified',
'Mon, 11 May 2020 15:01:48 GMT'), ('Content-Type', 'text/html'), ('Content-Leng
th', '93'), ('Date', 'Thu, 06 Aug 2020 13:23:28 GMT'), ('Server', 'server')]
-----Message-----
Accept-Ranges: bytes
ETag: W/"93-1589209308000"
Last-Modified: Mon, 11 May 2020 15:01:48 GMT
Content-Type: text/html
Content-Length: 93
Date: Thu, 06 Aug 2020 13:23:28 GMT
Server: server

喜欢的点个赞❤吧!