0%

python的参数传递

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

def add(a, b):
a = a + b
return a

def add_list(a, b):
a = a.append(b)
return a

if __name__ == '__main__':
c = [1, 3]
d = [2, 4]
add(c, d)
print(c)
c = add(c, d)
print(c)
e = 5
add_list(c, e)
print(c)
c = add_list(c, e)
print(c)

运行结果:

1
2
3
4
[1,3]
[1,3,2,4]
[1,3,2,4,5]
None
-------------这么快就看完啦^ω^谢谢阅读哟-------------