czsay 2020-01-30
‘‘‘值传递:传递的不可变类型string、tuple、number是不可变的‘‘‘def func1(num): print(id(num)) num = 10 print(id(num))temp = 20print(id(temp))func1(temp) #num = tempprint(temp)‘‘‘引用传递:传递的可变类型list、dict、set是可变的‘‘‘def func2(lis): lis[0] = 100li = [1,2,3,4,5]func2(li)print(li)a = 10b = 10b = 40print(id(a), id(b))c = 20d = 30print(id(c), id(d))d = cprint(id(c), id(d))