作者tumc (HIHIHI)
看板Python
标题[问题] unicode to big5
时间Sat Jun 18 22:17:12 2011
问一个笨问题
t=u'\u6211'
print t --> 我
如果有一网页上有 \u6211 这样的字串,那如何抓下来後转成big5呢
response = urllib2.urlopen(...
html=response.read()
html --> '\\u6211'
print html.encode('big5','ignore') --> '\u6211' 要如何得到"我"呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.161.246.198
1F:→ perturb:html.decode('unicode_escape').encode('big5') 06/18 23:17
2F:→ perturb:eval('u"%s"'%html) 06/18 23:17
3F:推 qsort:好奇问一下,为什麽会想要转成big-5 ? 06/18 23:45