urllib使用二

Posted 了解2号

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了urllib使用二相关的知识,希望对你有一定的参考价值。

urlopen方法返回一个html

对html使用info()方法返回HTTPMessage对象实例

import urllib

def print_list(lists):
    for i in lists:
        print(i)
html = urllib.urlopen("http://www.runoob.com/python/python-email.html")
#info()方法返回HTTPMessage实例
msg = html.info()
#HTTPMessage实例的方法:
#headers
#gettype()
#getheader()/getheaders()
#items()/keys()/values()
print_list(msg.headers)

 

以上是关于urllib使用二的主要内容,如果未能解决你的问题,请参考以下文章