Python 获取字符串中汉字的区位码
s = input('输入字符串:')
for c in s:
if 'u4e00' <= c <= 'u9fff':
print(f'{c}={ord(c)}', end=' ')
运行结果:
输入字符串:abe 天才就是入迷 good123
天=4476 才=1837 就=3045 是=4239 入=4075 迷=3552
原文地址: https://www.cveoy.top/t/topic/nE9S 著作权归作者所有。请勿转载和采集!