<分区> 分区>
如何迭代 [(1,2,3), (2,3,1), (1,1,1)] 并将每个元组拆分为头和尾? 我正在寻找像这样简洁的 pythonic 方式:
for h, *t in [(1,2,3), (2,3,1), (1,1,1)]:
# where I want t to be a tuple consisting of the last two elements
val = some_fun(h)
another_fun(val, t)
以上不适用于 python 2.7。
