回文数

代码实现
- 代码1是使用将整形数字倒置来进行对比,最后得出答案
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x<0:
return False
res=0
old=x
while x:
a=x%10
res=res*10+a
x//=10
return res==old
- 代码2是将整形数字强类型转换成字符串类型,再利用python中的切片从而达到字符串倒置的效果,最后直接进行比较就行
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
return str(x)==str(x)[::-1]




![[架构之路-222]:邮件服务与协议:POS3和SMTP](https://img-blog.csdnimg.cn/4ba33408e43946d5b1de5b08084c1717.png)














