Python:为什么不起作用?/这个错误到底是什么意思?

2024-09-30 14:37:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在得到了以下内容,但它不会在I上迭代。我不明白为什么它不起作用。b波长和吞吐量是列表。我似乎从0开始,但不会增加到1。你知道吗

ABconstant=[]

c=3e18
for i in range(0, ((len(Bwavelength))-1)):
    ABconstant1=(((3e18/((Bwavelength[i])**2))*throughput[i]))
    ABconstant.append(ABconstant1)
    i+=1
    a=Bwavelength[0]
    b=Bwavelength[-1]
    h=((b-a)/len(Bwavelength))
    ABflux = numpy.trapz(Bwavelength, ABconstant, h)
return ABflux

我得到的错误是:

Traceback (most recent call last):
  File "Rewrite17.11.2014.py", line 196, in <module>
    ABflux1 = ABconversion(Bwavelength, throughput)
  File "Rewrite17.11.2014.py", line 186, in ABconversion
    ABflux = numpy.trapz(Bwavelength, ABconstant, h)
  File "C:\Python27\lib\site-packages\numpy\lib\function_base.py, line 3234, in trapz
    ret = add.reduce(d * (y[slice1]+y[slice2]/2.0, axis)
ValueError: Operands could not be broadcast together with shapes (0,) (444,)

b波长和吞吐量相等。你知道吗

我不知道这到底是什么意思,尽管我查过了。你知道吗

提前谢谢。你知道吗


Tags: inpynumpylenline吞吐量file波长