题目:
方法:
class Solution:
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
a=''.join([x for x in s if x.isalpha() or x.isdigit()]).lower()
print(a)
if a == a[::-1]:
return True
return False
使用isdigit()和isalpha()判断是否为数字和字母
isdigit()判断是否为数字
isalpha()判断是否为字母
再判断是否为回文字符串。