在Python中,列表通过引用函数传递,对吧?
如果是这样,那里发生了什么?
>>> def f(a): ... print(a) ... a = a[:2] ... print(a) ... >>> b = [1,2,3] >>> f(b) [1, 2, 3] [1, 2] >>> print(b) [1, 2, 3] >>>
python reference function list python-2.7
function ×1
list ×1
python ×1
python-2.7 ×1
reference ×1