原理: 中文字符的编码范围是:
\u4e00 - \u9fff
只要编码在此范围就可判断为中文字符
以下代码Python2
下测试有效
1、判断字符串中是否包含中文
def is_contain_chinese(check_str):
"""
判断字符串中是否包含中文
:param check_str: {str} 需要检测的字符串
:return: {bool} 包含返回True, 不包含返回False
"""
for ch in check_str:
if u'\u4e00'
关注
打赏