Python2:
items = [1, 2, 3, 4]
a, b, c, d = items # Unpack items into variables
Python3:
a, *rest = items # a = 1, rest = [2,3,4]
a, *rest, d = items # a = 1, rest = [2,3], d = 4
*rest, d = items # rest = [1,2,3], d = 4
相关链接:
items = [1, 2, 3, 4]
a, b, c, d = items # Unpack items into variables
a, *rest = items # a = 1, rest = [2,3,4]
a, *rest, d = items # a = 1, rest = [2,3], d = 4
*rest, d = items # rest = [1,2,3], d = 4
相关链接: