【leetcode❤python】 7. Reverse Integer

#-*- coding: UTF-8 -*-
#2147483648
#在32位操作系统中,由于是二进制,
#其能最大存储的数据是1111111111111111111111111111111。
#正因为此,体现在windows或其他可视系统中的十进制应该为2147483647。
#32位数的范围是 -2147483648~2147483648
class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        x=int(str(x)[::-1]) if x>0 else -int(str(-x)[::-1])
        return x if x<2147483648 and x>=-2147483648 else 0

原文地址:https://www.cnblogs.com/kwangeline/p/6059597.html