python判断字符串是否包含或全是中文

参考: https://segmentfault.com/a/1190000017940752?utm_source=tag-newest

#检验是否全是中文字符
def is_all_chinese(strs):
    for _char in strs:
        if not '\u4e00' <= _char <= '\u9fa5':
            return False
    return True
#检验是否含有中文字符
def is_contains_chinese(strs):
    for _char in strs:
        if '\u4e00' <= _char <= '\u9fa5':
            return True
    return False

你可能感兴趣的:(python)