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)

猜你喜欢

转载自www.cnblogs.com/chillytao-suiyuan/p/9147655.html