函数和变量赋值Python

时间:2015-01-22 13:04:41

标签: python list sorting

a=[8,2,15,6,1]
a = a.sort()
print a

为什么打印None?你能详细说明所有功能吗?

1 个答案:

答案 0 :(得分:6)

sort()sorted()不同:

  • sort()就地对列表进行排序并返回None
  • sorted()创建一个新列表并将其返回。

有关详细信息,请参阅here

相关问题