1、查找網頁utf編碼
import urllib
if name == 'main' :
req = urllib.urlopen('自己想查看的網址')
html = req.read()
dehtml = html.decode('utf-8')
print dehtml
2、自動獲取網頁編碼
安裝 chardet
> python -m pip install chardet
import urllib
import chardet
if name == 'main' :
req = urllib.urlopen('自己想查看的網址')
html=req.read()
charset = chardet.detect(html)
print req.getcode()
print charset