python中如何反转list

反转list一共有3中方法

a=[1,2,3,4,5]

1、list(reversed(a));

2、sorted(a,revers=true)

3、a[: : -1]  其中[: : -1]代表从后向前取值,每次步进值为1,a【3: : -1】=[4,3,2,1] 代表从第3个坐标往前反转顺序输出,每次取1个值。

原文地址:https://www.cnblogs.com/amy7758/p/10894039.html