Pages - Menu

2018年8月23日 星期四

Atom 使用Atom-runner 印出中文


網路爬蟲繼續測試中,

但爬出來的文章就是會有亂碼,

上面那篇文章  CP950錯誤  解決後,一樣是不明的中文,

現在要更一勞永逸的解決。



import sys
import io
import requests
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
html = requests.get('http://activity.books.com.tw/everylettermatters/sentence/latest')
print(html.text)



出處  知呼


加上sys.stdout這段,那先前的CP950的編碼也不要再打了,

不然還是會錯誤。

沒有留言:

張貼留言