1. 程式人生 > >python 函式傳入引數

python 函式傳入引數

def test1(data):
    data += 1
    print data

a = 1
print a
test1(a)
print a

輸出:

1
2
1
def test2(data_list):
    data_list[0] += 10
    print data_list

tmplist = [1, 2, 3]
print tmplist
test2(tmplist)
print tmplist

輸出:

[1, 2, 3]
[11, 2, 3]
[11, 2, 3]