unicode汉字、数字、英文等字符范围表示

笔者小白在编写程序的时候遇到了需要知道汉字、数字、英文等其他字符的表示范围。

通过查询网上的资料,这里做一个总结:

#判断是否是汉字
def is_chinese(uchar):
    if uchar >= u'\u4E00' and uchar <= u'\u9FA5':
        return true
    else:
        return false
#判断是否是数字
def is_chinese(uchar):
    if uchar >= u'\u0030' and uchar <= u'\u0039':
        return true
    else:
        return false
#判断是否是英文字母
def is_chinese(uchar):
    if ( uchar >= u'\u0041' and uchar <= u'\u005A' ) or ( uchar >= u'\u0061' and uchar <= u'\u007A'):
        return true
    else:
        return false

参考资料:
1、https://wenku.baidu.com/view/f2d2dceaf524ccbff0218412.html 2017.7.26

你可能感兴趣的:(python,unicode)