AttributeError:“numpy.ndarray”对象没有“append”属性

2020-12-02 16:21:31 发布

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

我正在尝试运行第二页显示的代码:

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/video-lectures/lecture-20/lec20.pdf

在代码的底部,您必须添加以下行:

simFlips(100,100)

show()

下面是我在ubuntu上运行时得到的错误:

Traceback (most recent call last):
  File "coin.py", line 36, in <module>
    simFlips(100,100)
  File "coin.py", line 16, in simFlips
    diffs.append(abs(heads - tails))
AttributeError: 'numpy.ndarray' object has no attribute 'append'

请告诉我我做错了什么,这是我最后一个错误。提前谢谢!