1 2 3 4 5 6 7 8 9 |
>>> a, *b, c = range(7) #最初と最後の要素を省いてパッキング >>> a, b, c (0, [1, 2, 3, 4, 5], 6) >>> for a, *b in [(1, 3, 5), (3, 4, 5, 6, 7)]: # 最初の要素を省いてアンパッキング ... print(a, b) ... 1 [3, 5] # first, rest = seq[0], seq[1:] 3 [4, 5, 6, 7] |