解压变量
# swapa, b = b, a# 支持tuple和list的解压l = [1, 2]a, b = l# 在变量的组合中也可以生效a, b, c = 1, 3, (4, 5)# python会自动识别a, b, (c, d), e = 1, 3, (4, 5), 7
缺省元素
_, _, (c, d), _ = 1, 3, (4, 5), 7# 取值a = {}for _, v in a.items():print(v)
压缩变量
data = ['wheel', 'factory1', 3, 4, 5, 6, '2020-02-02']name, factory, *inch, date = dataprint(inch)
联合使用
data = ['wheel', 'factory1', 3, 4, 5, 6, '2020-02-02']name, factory, *_, date = data
