python实现get请求

python——get请求

import urllib.request

url = "http://www.csdn.net"

response = urllib.request.urlopen(url)
# 打印请求的状态码
print(response.getcode())
msg = response.read()
# 打印请求的网页内容的长度
print(len(msg))

输出:

200
1148023

Process finished with exit code 0

你可能感兴趣的:(Python,python,http)