函数内是否可以修改传递进来的列表

1 def test(a):
2     # a+=a
3     # a+=a是在原数据上的修改,而a=a+ashi先定义一个变量然后修改
4     a=a+a
5 
6     print(a)
7 num=[11,22,33,44]
8 test(num)
9 print(num)
View Code

yunxingyunyunxingjieguo :

E:\Python35\python.exe F:/Exercise/Python/test0731/登陆.py
[11, 22, 33, 44, 11, 22, 33, 44]
[11, 22, 33, 44]

Process finished with exit code 0

转载于:https://www.cnblogs.com/rourou1/p/6241296.html

你可能感兴趣的:(函数内是否可以修改传递进来的列表)