我正在创建一个newArrayList。每个signalxOP数组减去渐变,并且每个applyFieldOP数组都有多个。 (SignalxOP[] - Gradient) * appliedFieldOP[]
我该怎么做?以下是我尝试过的方法。它一直给我错误。
signalxOP = [5,4,3,2,1]
appliedFieldOP= [1,0.5,0,-0.5,-1]
Gradient = 1.5
newList = [[(x-Gradient)*y] for x,y in signalxOP,appliedFieldOP]
py.plot(appliedFieldOP,newList)
py.show()
newList = [[(x-Gradient)*y] for x,y in signalxOP,appliedFieldOP]
ValueError: too many values to unpack
答案 0 :(得分:3)
您可以使用zip
功能,就像这样
newList = [[(x-Gradient)*y] for x,y in zip(signalxOP,appliedFieldOP)]