copy
def hans_count(str):
hans_total = 0
for s in str:
if '\u4e00' <= s <= '\u9fef':
hans_total += 1
if '\u9FA6' <= s <= '\u9FFF':
hans_total += 1
if '\u3400' <= s <= '\u4DBF':
hans_total += 1
if '\u20000' <= s <= '\u2A6DF':
hans_total += 1
if '\u2A700' <= s <= '\u2B81D':
hans_total += 1
if '\u2B820' <= s <= '\u2CEA1':
hans_total += 1
if '\u2CEB0' <= s <= '\u2EBE0':
hans_total += 1
if '\u30000' <= s <= '\u3134A':
hans_total += 1
if '\u31350' <= s <= '\u323AF':
hans_total += 1
if '\u2F00' <= s <= '\u2FD5':
hans_total += 1
if '\u2E80' <= s <= '\u2EF3':
hans_total += 1
if '\u2F800' <= s <= '\u2FA1D':
hans_total += 1
if '\u31C0' <= s <= '\u31E3':
hans_total += 1
if '\u2FF0' <= s <= '\u2FFB':
hans_total += 1
if '\u3105' <= s <= '\u312F':
hans_total += 1
if '\u31A0' <= s <= '\u31BF':
hans_total += 1
return hans_total
汉字 Unicode 编码范围
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步