1. 程式人生 > >反轉整數--python

反轉整數--python

class Solution:
    def reverseX(self, x):
        if x>=pow(-2,31) and x <=pow(2,31)-1:
            print(x)
            a =list(reversed(list(str(abs(x)))))
            print(a)
            x = int(''.join(a))*int(x/abs(x))
            print(x)
        if ((x<pow(-2,31)) or (x>pow(2,31)-1)):
                    return 0
        return x
        
        
        """
        :type x: int
        :rtype: int
        """