[問題] 為什麼可以assign但不能print出來

看板Python作者 (謝謝你9527)時間9年前 (2016/02/02 16:58), 9年前編輯推噓1(104)
留言5則, 4人參與, 最新討論串1/1
我用beautifulsoup的get_text()抓資料 想要print出來看對不對 print(trs[0].get_text().encode("UTF-8").decode("UTF-8")) 結果一直出現錯誤 UnicodeEncodeError: 'cp950' codec can't encode character '\u7c7b' in position 0: illegal multibyte sequence 但卻可以assign a = trs[0].get_text().encode("UTF-8").decode("UTF-8") 但一樣不能把a print出來 想請問這中的原因是甚麼...? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.233.83.112 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1454403535.A.206.html

02/02 17:09, , 1F
你google cp950就有答案了
02/02 17:09, 1F

02/02 17:10, , 2F
windows cmd print 問題
02/02 17:10, 2F
所以裡面值應該沒問題 是print的問題嗎? ※ 編輯: peace9527 (36.233.83.112), 02/02/2016 17:12:03

02/02 17:59, , 3F
不是 print 的問題, 是 Windows 的問題
02/02 17:59, 3F

02/02 19:25, , 4F
你一定要看的話,用IDLE是能看,但強烈不建議用就是了
02/02 19:25, 4F

02/02 22:41, , 5F
log到檔案裡吧
02/02 22:41, 5F
文章代碼(AID): #1Mi6_F86 (Python)
文章代碼(AID): #1Mi6_F86 (Python)