Created
April 29, 2020 17:26
-
-
Save AntiKnot/4b23667a5f49e6f18c504cb66d76e578 to your computer and use it in GitHub Desktop.
python sort; python内置排序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| l1 = [1, 2, 3] | |
| l2 = list.sort(l1) | |
| l3 = l1.sort() | |
| l4 = sorted(l1) | |
| def myprint(l): | |
| print("{}, id:{}".format(l, id(l))) | |
| return 0 | |
| if __name__ == '__main__': | |
| myprint(l1) | |
| myprint(l2) | |
| myprint(l3) | |
| myprint(l4) | |
| """ | |
| [1, 2, 3], id:4487356296 | |
| None, id:4485415016 | |
| None, id:4485415016 | |
| [1, 2, 3], id:4487356360 | |
| """ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorted 返回排序后新的列表对象
sort 在修改原列表对象