iT邦幫忙

0

(Python3) Big5 Character code table 字串處理

  • 分享至 

  • twitterImage

各位大神們好,小弟目前有個疑問小請教

例如有個list=['A741', 'A66E', 'B6DC'],其對應的Big5碼是"你好嗎"。

我要用程式將"A741"對應成"你",以此類推,並且存於txt檔中,若一些不在碼簿中的字都用空白取代掉。

網路上抓到的Big5 charactor table是"http://ash.jp/code/cn/big5tbl.htm"

目前的想法是弄成矩陣,若沒有對應到中文的碼就是填空白或問號,可能用於之後判斷。

但想請問大神們對於Big5 charactor table怎麼處理有什麼想法嗎?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
willvegapunk
iT邦新手 5 級 ‧ 2018-03-26 00:19:30

建議你用 dict 來建構你的code book
對於不在 code book 裡面的東西,用 dict.get('key',"找不到就return此string")

codebook = dict(zip( ('A741', 'A66E', 'B6DC'),("你","好","嗎")))
codebook.get('A123',' ') # 實現空白功能

其他的東西就去查一下 dict 的 document
ref: https://docs.python.org/3/tutorial/datastructures.html

sleepgary iT邦新手 5 級 ‧ 2018-03-26 16:17:51 檢舉

好的 感謝willvegapunk大大幫忙~

我要發表回答

立即登入回答