#!/usr/bin/python# -*- coding: utf-8 -*-'''
英文:Determine whether an integer is a palindrome. Do this without extra space.
中文:判断一个数是不是回文数字
举例:12345 不是 12321 是,注意:leetcode中负数都不是回文数字
'''classSolution(object):'''将数字翻转后,判断两个数字是否相等'''defisPalindrome(self, x):"""
:type x: int
:rtype: bool
"""if x < 0:
returnFalse
m = x
n = 0while x:
n = n * 10 + x % 10
x = x/10returnTrueif m == n elseFalseif __name__ == "__main__":
s = Solution()
print s.isPalindrome()