1.编码范围
https://blog.csdn.net/mouday/article/details/81512870
import sys def check_contain_chinese(check_str): for ch in check_str.encode('utf-8').decode('utf-8'): if u'u4e00' <= ch <= u'u9fff': return True return False print(check_contain_chinese('i love yiu ')) print(check_contain_chinese('i love you')) print(check_contain_chinese('()'))
很多博客都是这么写的,但是它并不能判断中文符号。
像上面中文的括号,就不在上述范围内。