看板 Python 關於我們 聯絡資訊
小弟在網路上練習爬 爬到'林忆莲',但運行時簡體怎麼都print不出來 嘗試方法如下未果,懇求大大幫助 #coding=utf-8 singer=u'林忆莲' (爬到的) print singer.encode('cp950','replace').decode('cp950') #林?? 感恩~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 192.83.177.90 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1499840589.A.829.html
Neisseria: 終端機本身的編碼是? 07/12 15:01
coeric: i j 是啥碗糕 07/12 15:15
※ 編輯: coolching (192.83.177.90), 07/12/2017 16:11:50
coolching: 抱歉寫的不清楚,終端機是cp950 07/12 16:13
coolching: 使用python2.7 07/12 16:23
zerof: 改用 python3.6 選我正解 07/12 17:19
uranusjr: CP950 你試一百年也印不出簡體字啦 07/12 20:27
uranusjr: Python 3.6 真的是正解因為預設終端編碼 UTF-8 07/12 20:28
eight0: 試試 safeprint https://pypi.python.org/pypi/safeprint 07/12 22:40