test01

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')#设置系统默认编码.

import urllib2

response = urllib2.urlopen('http://js.qq.com')
html = response.read()

print html

以及

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')#设置系统默认编码.

import urllib2

req = urllib2.Request('http://js.qq.com')
response = urllib2.urlopen(req)
the_page = response.read()

print the_page

你可能感兴趣的:(test01)