Skip to content

Instantly share code, notes, and snippets.

@RagtagGeoduck
Last active March 11, 2020 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RagtagGeoduck/abacc0840bf1667d84c10622ca1aabc6 to your computer and use it in GitHub Desktop.
Save RagtagGeoduck/abacc0840bf1667d84c10622ca1aabc6 to your computer and use it in GitHub Desktop.
[Python反转list的三种方法] 对列表的内容进行倒置 #Python
list(reversed(a)) #reversed(a)返回的是迭代器,所以前面加个list转换为list
sorted(a,reverse=True)
a[: :-1] #其中[::-1]代表从后向前取值,每次步进值为1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment