#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__="byx54192@gmail.com" class Solution: def reverse(self, x): """ :type x: int :rtype: int """ if x<0: x=abs(x) restr=[x for x in str(x)] restr.reverse() renum=int(''.join(restr)) return 0-self.judge(renum) if x>=0: restr=[x for x in str(x)] restr.reverse() renum=int(''.join(restr)) return self.judge(renum) def judge(self,renum): if renum > 2**31: return 0 else: return renum