2024-06-01 05:17:16 发布
网友
我有一个symphy解算器的有序对列表,[(a,b),(c,d), etc.] 我需要将这些值转换为一个列表,以插入另一个函数,如:
[(a,b),(c,d), etc.]
def func1(a, b): do_stuff print_stuff
我尝试使用list(zip(*foo))但是它返回了
list(zip(*foo))
[(-1.21566973175616,), (2.39458716469521,)]
这是没用的。对python(comp。物理课)。你知道吗
我不是100%确定你在问什么,但我希望这会有所帮助
lst = [(1,2),(3,4),(5,6)] def func1(a,b): stuff = a+b # random 'do_stuff' print(stuff) for x in lst: func1(*x) # the * will unpack x so that it will be accepted into the foo function, you could also do func1(x[0],x[1])
如果我理解正确,你只是在找^{}。你知道吗
>>> l = [(4, 3), (2, 6), (10, 2)] >>> list(chain(*l)) [4, 3, 2, 6, 10, 2]
我不是100%确定你在问什么,但我希望这会有所帮助
如果我理解正确,你只是在找^{} 。你知道吗
相关问题 更多 >
编程相关推荐