python3请求osc显示[Decode error - output not utf-8]

yak 发布于 2013/05/19 13:34
阅读 2K+
收藏 0
# -*- coding=utf8 -*-
import urllib.request
url="http://www.oschina.net"
req_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
  
             }
req = urllib.request.Request(url,None,req_header)
resp = urllib.request.urlopen(req)
html = resp.read().decode('utf8','ignore')
print(html)
在sublime是执行,提示

[Decode error - output not utf-8][Decode error - output not utf-8][Decode error - output not utf-8]


加载中
0
yak
yak
安装了个最新的production版本python3.3,在命令行能运行了,但是明显不是utf8
返回顶部
顶部