python 添加list元素

def extend_list(val,list=[]):
list.append(val)
return list

list1 = extend_list(10)
list2 = extend_list(123,[])
list3 = extend_list('a')

print(list1)
print(list2)
print(list3)


默默的想一想答案是什么:




C:\Users\san\AppData\Local\Programs\Python\Python36-32\python.exe E:/love/tongcheng.py
[10, 'a']
[123]
[10, 'a']

进程已结束,退出代码0

can you explain why ? if you can't ,you should read more 




猜你喜欢

转载自www.cnblogs.com/wudeng/p/9469771.html