小编Sli*_*inc的帖子

Python传递列表作为参数

如果我要运行此代码:

def function(y):
    y.append('yes')
    return y

example = list()
function(example)
print(example)
Run Code Online (Sandbox Code Playgroud)

为什么它会返回['yes'],即使我没有直接更改变量'example',我怎么能修改代码以便'example'不受函数的影响?

python arguments function list

23
推荐指数
3
解决办法
8万
查看次数

标签 统计

arguments ×1

function ×1

list ×1

python ×1