def is_chinese(uchar):
"""判断一个unicode是否是汉字"""
if uchar >= u'\u4e00' and uchar <= u'\u9fff':
return True
else:
return False
def is_number(uchar):
"""判断一个unicode是否是数字 此函数用str.isdigit()代替也可"""
if uchar >= u'\u0030' and uchar <= u'\u0039':
return True
else:
return False
def is_alphabet1(uchar):
"""判断一个unicode是否是英文字母 函数1"""
if (uchar >= u'\u0041' and uchar <= u'\u005a') or (uchar >= u'\u0061' and uchar <= u'\u007a'):
return True
else:
return False
def is_alphabet2(uchar):
"""判断一个unicode是否是英文字母 函数2"""
return bool(re.search('[a-zA-Z]', uchar))
def is_other(uchar):
"""判断是否非汉字,非数字和非英文字符"""
if is_number(uchar) or is_chinese(uchar) or is_alphabet(uchar):
return False
else:
return True