如何检查字符串中的字符是否为字母? (Python) - How can I check if character in a string is a letter? (Python)

问题:

I know about islower and isupper , but can you check whether or not that character is a letter?我知道islowerisupper ,但是你能检查那个字符是否是一个字母吗? For Example:例如:

>>> s = 'abcdefg'
>>> s2 = '123abcd'
>>> s3 = 'abcDEFG'
>>> s[0].islower()
True

>>> s2[0].islower()
False

>>> s3[0].islower()
True

Is there any way to just ask if it is a character besides doing .islower() or .isupper() ?除了做.islower().isupper()之外,还有什么方法可以询问它是否是一个字符?


解决方案:

参考一: https://en.stackoom.com/question/13HRo
参考二: https://stackoom.com/question/13HRo
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章