Python爬蟲中文亂碼

方法一

手動設定相應數據的編碼格式:

response = requests.get(url=url,headers=headers).text
response.encoding = 'utf-8'
response = response.text

方法二

通用處理中文亂碼的解決方案

new_name = img_name.encode('iso-8859-1').decode('gbk')

關於encode和decode的解釋:
https://www.cnblogs.com/wangcuican/p/11191011.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章