王锋 今天 17:06 | 2次浏览 | 0条评论
# 安装:pip install ltchinese
import ltchinese.conversion as conv
char = '永'
# 获取Unicode编码
ucn = conv.python_to_ucn(char)
print(f"Unicode编码:{ucn}") # 输出:U+6C38
# 获取NCR(数值字符引用)
ncr = conv.python_to_ncr(char)
print(f"NCR编码:{ncr}") # 输出:永
# 获取EUC-CN编码(GB2312外部编码)
euc = conv.python_to_euc(char)
print(f"EUC-CN编码:{euc}") # 输出:d3c0(十六进制)
Zeuux © 2026
京ICP备05028076号
暂时没有评论