0
是否有一種簡單的方法來檢測Python 3中的字符串使用哪些寫入系統?在Python中檢測字符串的寫入系統
例如:
- 「山本」 →拉丁字母
- 「山本」 →漢字
- 「やまもと」 →平假名
- 「Ямамото」 →西里爾 等
是否有一種簡單的方法來檢測Python 3中的字符串使用哪些寫入系統?在Python中檢測字符串的寫入系統
例如:
繼承人一個襯墊(Python的3.X) -
import unicodedata
langname = lambda x : unicodedata.name(x[0]).split(' ')[0]
輸出 -
>>> langname('Yamamoto')
'LATIN'
>>> langname('やまもと')
'HIRAGANA'
快速谷歌搜索刪除了這個:alphabet-detection。
您可以使用它作爲文檔狀態:
>>> from alphabet_detector import AlphabetDetector
>>> ad = AlphabetDetector()
>>> ad.detect_alphabet(u'Cyrillic and кириллический')
{'CYRILLIC', 'LATIN'}
這個庫在 - 事實上使用與我的答案相同的方法!要點是你不需要安裝另一個庫來完成這樣簡單的任務:) – hashcode55
@ hashcode55的確如此。沒有深入瞭解,它似乎是一個簡單的*模塊。 –
是啊,86星也太哈哈了。 – hashcode55