[Python编程300例]例1 反转一个3位整数

# coding: utf-8
class Solution(object):
    def reverse_num(self, num):
        hundreds = num/100
        tens = num % 100/10
        ones = num % 10
        return ones*100 + tens*10 + hundreds


if __name__ == '__main__':
    solution = Solution()
    num = solution.reverseNum(800)
    print (num)

猜你喜欢

转载自blog.csdn.net/weixin_45329445/article/details/116035349
今日推荐