import urllib.request
import urllib.parse
import re
import time
import json
url = 'http://shike.gaotie.cn/checi.asp?checi=G1'
respond = urllib.request.urlopen(url= url)
html = respond.read()
respond.close()
html = html.decode('ascii')
//这一句话出错了
上面是程序,是使用Python3 实现的。
求各位大神指教
html = html.decode('gb2312')
128 让我想到了int和Integer自动装箱和拆箱的范围 -128< <127,python不知道跟这个有没有关系
html.decode('ascii')这句使用ascii编码解码http://shike.gaotie.cn/checi.asp?checi=G1的返回内容,但是http://shike.gaotie.cn/checi.asp?checi=G1的返回内容的编码格式为charset=gb2312,所以应相应修改html.decode('gb2312')。试试呗。。。。