马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
>>> listn=[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> listn
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> listn.reverse()
>>> listn
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> listn.sort(reverse=True)
>>> listn
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> listn.sort(reverse=False)
>>> listn
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> listn.sort(sort=True)
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
listn.sort(sort=True)
TypeError: 'sort' is an invalid keyword argument for sort()
>>>
最后为什么会报错了呢??list.sort(reverse=True)合法,为什么换成(sort=True)就BUG了呢?
|