整除和求模:定位个十百位

    1. """
    2. 正整数的反转
    3. """
    4. num = int(input('num = '))
    5. reversed_num = 0
    6. while num > 0:
    7. reversed_num = reversed_num * 10 + num % 10
    8. num //= 10
    9. print(reversed_num)

    切片操作:复制列表or倒转列表

    1. fruits = ['grape', 'apple', 'strawberry', 'waxberry']
    2. # 可以通过完整切片操作来复制列表
    3. fruits3 = fruits[:]
    4. print(fruits3) # ['grape', 'apple', 'strawberry', 'waxberry', 'pitaya', 'pear', 'mango']
    5. # 可以通过反向切片操作来获得倒转后的列表的拷贝
    6. fruits5 = fruits[::-1]
    7. print(fruits5) # ['mango', 'pear', 'pitaya', 'waxberry', 'strawberry', 'apple', 'grape']