def add(x,y): return x + y sum = add(3,5) #print(sum) dict = {"add":add} sum1 = dict.get("add")(4,6)
通过传参把列表list传进去,在调用的方法中添加元素,原来的列表list也就成功添加了元素
def addItem(list): print(type(list)) list.append("aaas") list.append("bbbss") def test(): list = [] print(type(list)) addItem(list) print(list) test()
标签:函数,python,list,add,append,print,def,字典 From: https://www.cnblogs.com/sgj191024/p/17766261.html