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)

 

posted @ 2018-06-06 22:06  了解2号  阅读(102)  评论(0编辑  收藏  举报