整数反转与回文数检验 LeetCode9 java解答的python版本 class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x<0: return False if x%10==0: #以0结尾的数中,只有0本身是回文数 if x==0: return True return False y=0 w=x while w>y: c=w % 10 w=w//10 y=y*10+c return w==y or w==y//10 #对于奇数位输入,消除中间位值得影响