Pages - Menu

2018年8月23日 星期四

Python 的 CP950 錯誤

語言:Python 3.6
IDE:ATOM
執行環境:Atom-runner


在搞網路爬蟲時,
抓下來的中文字,輸出會變成亂碼,此時可以直接改成

import requests
html = requests.get('http://tw.yahoo.com')
print(html.text.encode("utf8").decode("cp950", "ignore"))


加上

.encode("utf8").decode("cp950", "ignore"))


後解決,但還是變成不明中文..,
所以又延伸出了另一個解決方式  Atom 使用Atom-runner 印出中文
出處:碼人日誌

沒有留言:

張貼留言