reverse(), extend(), sort() methods of list

>>> l = list('sdf')
>>> l
['s', 'd', 'f']
>>> id(l)
4520422000
>>> l.reverse()
>>> id(l)
4520422000
>>> l.extend(list('fff'))
>>> id(l)
4520422000
>>> l.sort()
>>> id(l)
4520422000

  对list使用上述方法不会产生新对象,而是在对象本身上操作。

原文地址:https://www.cnblogs.com/iNeoWong/p/4718692.html