python判断是否是英文字母_用python如何判断字符串是纯英文
用python如何判斷字符串是純英文
發(fā)布時(shí)間:2020-11-11 09:31:24
來(lái)源:億速云
閱讀:97
作者:小新
這篇文章主要介紹用python如何判斷字符串是純英文,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
判斷一個(gè)字符是否為漢字,英文字母,數(shù)字,空還是其他# 使用Unicode編碼來(lái)判斷
def is_chinese(uchar):
"""判斷一個(gè)unicode是否是漢字"""
if u'\u4e00' <= uchar <= u'\u9fa5':
return True
else:
return False
def is_number(uchar):
判斷一個(gè)unicode是否是數(shù)字if u'\u0030' <= uchar <= u'\u0039':
return True
else:
return False
def is_alphabet(uchar):
判斷一個(gè)unicode是否是英文字母if (u'\u0041' <= uchar <= u'\u005a') or (u'\u0061' <= uchar <= u'\u007a'):
return True
else:
return False
def is_space(uchar):
以上是用python如何判斷字符串是純英文的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
總結(jié)
以上是生活随笔為你收集整理的python判断是否是英文字母_用python如何判断字符串是纯英文的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: zincrby redis python
- 下一篇: python输入姓名输出欢迎_pytho