方法一:
class Solution:
def isPalindrome(self, x: int) -> bool:
if x<0:
return False
if x<10:
return True
res=0
num=x
while x>0:
ele=x%10
x=x//10
res=res*10+ele
if res==num:
return True
else:
return False
方法二:
class Solution:
def isPalindrome(self, x: int) -> bool:
if x<0:
return False
if x<10:
return True
s=str(x)
if s==s[::-1]:
return True