根据GreenTreeSnakes documentation on Assignment statements报告:
An assignment.
targets
is a list of nodes, andvalue
is a single node.Multiple nodes in
targets
represents assigning the same value to each. Unpacking is represented by putting aTuple
orList
withintargets
.
我的问题是,什么时候解包会将目标放在列表中而不是元组中?给出的示例解压成一个元组
在赋值中,目标既可以是列表,也可以是元组:
这种差异对Python来说是表面上的;见Assignment statement reference documentation
演示:
相关问题 更多 >
编程相关推荐