运行环境:
Python3.6
、requests2.18.4
In[2]: import requests
In[3]: res = requests.get('http://baidu.com')
In[4]: res
Out[4]: 200]>
In[5]: res.encoding
Out[5]: 'ISO-8859-1'
In[2]: import chardet
In[3]: from urllib.request import urlopen
In[4]: url = 'http://www.baidu.com'
In[5]: html = urlopen(url).read()
In[6]: print(chardet.detect(html))
{'encoding': 'utf-8', 'confidence': 0.99, 'language': ''}