1、簡單解釋就是:反轉一個序列對象 例子1: def fun3(): x = [3,6,9] for i in reversed(x): print(i,end=',')fun3() 輸出: 》》》9,6,3, 例子2: >>> a = range(5)>>> arange(0, 5)>>> lis ...
1、簡單解釋就是:反轉一個序列對象
例子1:
def fun3():
x = [3,6,9]
for i in reversed(x):
print(i,end=',')
fun3()
輸出:
》》》9,6,3,
例子2:
>>> a = range(5)
>>> a
range(0, 5)
>>> list(a)
[0, 1, 2, 3, 4]
>>> a1 = reversed(a)
>>> list(a1)
[4, 3, 2, 1, 0]