首先调用urlopen需要导入urllib.request模块。
urllib.request :
urlopen() : 简单来说就是打开一个URL.
url : 来自百度百科
urlopen的返回值,测试:
可见返回值是http.client.HTTPResponsed对象。
http.client.HTTPResponsed对象:
详情参考:https://docs.python.org/3/library/http.client.html#http.client.HTTPSConnection
例子:
http://learncodethehardway.org/words.txt的内容为:
代码:
打印: