>>>
>>> a = [1,5,3,2]
>>> sorted(a)
[1, 2, 3, 5]
>>> a
[1, 5, 3, 2]
>>> a.sort()
>>> a
[1, 2, 3, 5]
>>>
>>>

 

sorted(list) 和 list.sort()的不同之处:
    使用sorted(list)  将改变list
    使用list.sort()     不会改变list
 
 

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-28
  • 2021-10-21
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案