leetcode- 整数反转

# -*- coding: utf-8 -*-
"""
Created on Sat Jul 17 12:40:04 2021

@author: luogantt
"""

class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        pp=1
        xs=list(str(x))
        if x<0:
            pp=-1
            xs=xs[1:]
    
        print(xs)
        n=len(xs)
        print(n)
        x1=0

        for p in range(n):
            print(int(xs[n-1-p])*10**(n-1))
            x1=x1+int(xs[n-1-p])*10**(n-p-1)
        return x1*pp
c=Solution()
a=12309
c1=c.reverse(a)

print('c1=',c1)
    
上一篇:3.linux基础自建命题


下一篇:RHEL6 或CentOS 6配置共享存储--使用iSCSI