题目描述请点击查看LeetCode 题目描述
Python3 代码解答如下:
class Solution:
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x < 0:
return False
else:
s = str(x)
a = (len(s)+1)//2 #求回文数的中间的数字到起始的长度
isSame = True
for i in range(0, a):
if s[i] != s[-(i+1)]: #判断第1个与最后1个字符是否相等
isSame = False
break
print(isSame)
return isSame