python内置变量-reversed(seq)
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]
现在学习还不晚;