python3之后已经改版了,我们只需要换一个使用的方法就可以了如下所示:
import urllib.request
# 向指定URL发送请求并且返回服务器响应的类文件对象
response=urllib.request.urlopen("http://www.baidu.com")
# 服务器返回的类文件支持python的对象文件操作
# read()读取URL里的所有文件
html=response.read()
print(html)
请叫我程序员雷锋,不用谢!
python3之后已经改版了,我们只需要换一个使用的方法就可以了如下所示:
import urllib.request
# 向指定URL发送请求并且返回服务器响应的类文件对象
response=urllib.request.urlopen("http://www.baidu.com")
# 服务器返回的类文件支持python的对象文件操作
# read()读取URL里的所有文件
html=response.read()
print(html)
请叫我程序员雷锋,不用谢!