我想知道有什么方法可以在 Python 3 中检查汉字是简体中文还是繁体中文?
请您参考如下方法:
cjklib
不支持 Python 3。在 Python 3 中,您可以使用 hanzidentifier
.
import hanzidentifier
print(hanzidentifier.has_chinese('Hello my name is John.'))
》 False
print(hanzidentifier.has_chinese('Country in Simplified: 国家. Country in Traditional: 國家.'))
》 True
print(hanzidentifier.is_simplified('John说:你好!'))
》 True
print(hanzidentifier.is_traditional('John說:你好!'))
》 True