python中的a[::1]类型和用法

这个是python的slice notation的特殊用法

for value in rang(10)涉及的数字倒序输出:
for value in rang(10)[::-1]涉及的数字倒序输出:

# 按相反的顺序输出列表的值
def test6():
    data6 = ['one', 'two', 'three']
    for i in data6[::-1]:
        print(i)

a = test6()

在这里插入图片描述

参考:https://blog.csdn.net/qq_41940950/article/details/80765674

猜你喜欢

转载自blog.csdn.net/u014150715/article/details/111274766