python判断是否是英文字母_用python如何判断字符串是纯英文

用python如何判断字符串是纯英文

发布时间:2020-11-11 09:31:24

来源:亿速云

阅读:97

作者:小新

这篇文章主要介绍用python如何判断字符串是纯英文,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

判断一个字符是否为汉字,英文字母,数字,空还是其他# 使用Unicode编码来判断

def is_chinese(uchar):

"""判断一个unicode是否是汉字"""

if u'\u4e00' <= uchar <= u'\u9fa5':

return True

else:

return False

def is_number(uchar):

判断一个unicode是否是数字if u'\u0030' <= uchar <= u'\u0039':

return True

else:

return False

def is_alphabet(uchar):

判断一个unicode是否是英文字母if (u'\u0041' <= uchar <= u'\u005a') or (u'\u0061' <= uchar <= u'\u007a'):

return True

else:

return False

def is_space(uchar):

以上是用python如何判断字符串是纯英文的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

你可能感兴趣的:(python判断是否是英文字母)