判断汉字 使用 unicode 范围 \u4e00 - \u9fff 来判别汉字,unicode 分配给汉字(中日韩越统一表意文字)的范围为 4E00-9FFF
#http://www.unicode.org/charts/PDF/U4E00.pdf
#http://luopuya.github.io/2014/03/29/Python%20%E5%88%A4%E6%96%AD%E6%B1%89%E5%AD%97%E5%AD%97%E7%AC%A6/
# py3
def ishan(text):
# for python 3.x
# sample: ishan('一') == True, ishan('我&&你') == False
return all('\u4e00' <= char <= '\u9fff' for char in text)
#py2
def ishan(text):
# for python 2.x, 3.3+
# sample: ishan(u'一') == True, ishan(u'我&&你') == False
return all(u'\u4e00' <= char <= u'\u9fff' for char in text)