#在python中一个汉字算一个字符,一个英文字母算一个字符
#用 ord() 函数判断单个字符的unicode编码是否大于255即可。
def is_contain_chinese(check_str):
#check_str是一个unicode编码的字符。例如
#check_str=u'fff好几个'
for ch in check_str:
#if u'\u4e00' <= ch <= u'\u9fff':
if ord(ch) > 255:
print(ch)
如何判断字符串中包含中文
最新推荐文章于 2023-10-30 20:08:27 发布