[問題] 程式輸出 pipe redirect 與 UnicodeEncodeError
我有一個程式會 print 出中文, 如下
bash-3.2$ ./test.py
油品行銷事業部台北市信義區松仁<b>路三號總機:(02)8789-8989 傳真:(02)8789</b>-9050 免費 服務專線:0800-036188 電子服務信箱:D001830@cpc.com.tw <b>...</b>
地址: 11010台北市信義區松仁<b>路三號/ 總機: 02-8789-8989 / 傳真: 02-8789</b>-9000 加油 站客服電話: 0800-036188/網站瀏覽人數:3397635 人 <b>...</b>
但是當我想把輸出寫到一個檔案 或是pipe到more的時候
bash-3.2$ ./test.py |more
Traceback (most recent call last):
......
UnicodeEncodeError:
'ascii' codec can't encode characters in position 0-14:
ordinal not in range(128)
請問我做錯了什麼?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.58.176
Python 近期熱門文章
PTT數位生活區 即時熱門文章