作者peace9527 (谢谢你9527)
看板Python
标题[问题] 为什麽可以assign但不能print出来
时间Tue Feb 2 16:58:53 2016
我用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://webptt.com/cn.aspx?n=bbs/Python/M.1454403535.A.206.html
1F:→ waitingjune: 你google cp950就有答案了 02/02 17:09
2F:→ waitingjune: windows cmd print 问题 02/02 17:10
所以里面值应该没问题 是print的问题吗?
※ 编辑: peace9527 (36.233.83.112), 02/02/2016 17:12:03
3F:→ uranusjr: 不是 print 的问题, 是 Windows 的问题 02/02 17:59
4F:→ ResolaQQ: 你一定要看的话,用IDLE是能看,但强烈不建议用就是了 02/02 19:25
5F:推 IKAFIRE: log到档案里吧 02/02 22:41