您需要使用
tuple()或
list()将生成器表达式转换为
list或
tuple:
[tuple((fir[0], fir[1]*sec[1], fir[2]*sec[2]) for fir in first_lst) for sec in second_lst if fir[0] == sec[0]]
您的代码的工作版本:
>>> first_lst = [tuple(float(y) for y in x) for x in first_lst]>>> second_lst = [tuple(float(y) for y in x) for x in second_lst]>>> [((fir[0],) + tuple(x*y for x, y in zip(fir[1:], sec[1:]))) for fir in first_lst for sec in second_lst if fir[0]==sec[0]][(-2.5, 0.9359, 1.0555999999999999), (-2.0, 0.9516000000000001, 1.04)]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)