9.回文数

class Solution:
    def isPalindrome(self, x: int) -> bool:
        # 参考 7.整数反转
        num = 0
        a = abs(x)
        while(a != 0):
            temp = a % 10
            num = num*10 + temp
            a = a//10
        if x >= 0 and x == num:
            return True
        else:
            return False

 

posted @ 2019-08-21 22:13  我叫郑小白  阅读(85)  评论(0编辑  收藏  举报