小编har*_*rry的帖子

Python 中的 arr 和 arr[:] 有什么区别?

我想知道列表变量本身和后跟 [:] 的列表变量之间的区别

例如,

# When nums are List[int] and res are List,
# what is the difference between
res.append(nums[:])
# and 
res.append(nums)
Run Code Online (Sandbox Code Playgroud)

我在实现递归置换函数时提出了我的问题

# When nums are List[int] and res are List,
# what is the difference between
res.append(nums[:])
# and 
res.append(nums)
Run Code Online (Sandbox Code Playgroud)

提前感谢您的帮助!

python list python-3.x

0
推荐指数
1
解决办法
387
查看次数

标签 统计

list ×1

python ×1

python-3.x ×1