resp = requests.get(url)
resp.content 是str類型
resp.text是unicode類型
如果返回的中文使用gbk編碼,需要轉換成utf-8的時候:
resp.content.decode('gb2312').encode('utf-8')
resp.content.decode('gb2312') #從gbk轉unicode
resp.content.decode('gb2312').encode('utf-8') #將unicode編碼編譯成utf-8