判断一个python字符串中是否包含中文字符

#在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)

参考文档:https://blog.csdn.net/mouday/article/details/81512870

原文地址:https://www.cnblogs.com/taoyuanming/p/10825558.html