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)