解析:
解法1:转换为字符串
解法2:用数学计算反转
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
xx = x
if x < 0:
return False
reverse = 0
while x > 0:
tmp = x%10
x = x//10
#先取余后取整(先取整会改变数字)
reverse = reverse * 10 + tmp
return reverse == xx