作者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
→ perturb:html.decode('unicode_escape').encode('big5') 06/18 23:17
→ perturb:eval('u"%s"'%html) 06/18 23:17
推 qsort:好奇問一下,為什麼會想要轉成big-5 ? 06/18 23:45