解题思路

要验证一个数字是否是对称的,只须要将它的信息保留到一个能够实现翻转的数据类型就好了

步骤

  1. 将数据类型转换成str
  2. 验证生成的str是否对称

原题链接
欢送在我的博客摸索更多思路

代码

class Solution(object):    def isPalindrome(self, x):        str_num=str(x)        if str_num==str_num[::-1]:            return True        else:            return False