拆包 适用于元组和列表
coordinates = (1, 2, 3)
如果想要获取这三个值 本来应该这样做
x=coordinates[0]
y=coordinates[1]
z=coordinates[2]
python 特性:简化获取步骤
x, y, z = coordinates
输出中全是变量名,可以直接用 , 连接
print(x, y, z)
Python:拆包
2024-07-19 06:00:02 19 阅读
拆包 适用于元组和列表
coordinates = (1, 2, 3)
如果想要获取这三个值 本来应该这样做
x=coordinates[0]
y=coordinates[1]
z=coordinates[2]
python 特性:简化获取步骤
x, y, z = coordinates
输出中全是变量名,可以直接用 , 连接
print(x, y, z)