如何檢查字符串中的字符是否爲字母? (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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章