拆包 适用于元组和列表
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 16:36:18 发布
拆包 适用于元组和列表
coordinates = (1, 2, 3)
如果想要获取这三个值 本来应该这样做
x=coordinates[0]
y=coordinates[1]
z=coordinates[2]
python 特性:简化获取步骤
x, y, z = coordinates
输出中全是变量名,可以直接用 , 连接
print(x, y, z)