我正在试着得到梳子的结果。但是下面的错误随之而来。 我能得到解决错误的建议吗?你知道吗
import math
def chirp(n):
l=[]
for i in range(3141):
i1=i/10.
s=math.sin(n*i1)
l=l.append(s)
return l
l1=chirp(10,1)
l2=chirp(20,1)
l3=chirp(40,1)
comb= l1+l2+l3
print comb
错误:
Traceback (most recent call last):
File "test.py", line 17, in <module>
l1=chirp(10,1)
File "test.py", line 15, in chirp
l=l.append(s)
AttributeError: 'NoneType' object has no attribute 'append'
好吧,你在传递
chirp()
两个位置参数。。。你用,
作为小数吗?你知道吗这对我来说没有错误。注意
l.append(s)
的就地使用。你知道吗换条线
为了公正
append
改变列表,因此不必查看返回值(即None
)。你知道吗相关问题 更多 >
编程相关推荐