*)TypeError: exceptions must derive from BaseException

  原因是raise语句没有写好

raise('value must between 0 and 100')
#应该是
raise valueError('value must between 0 and 100')

  第一次出现抛出的异常就有错误,我没有仔细看,给当成了是正常抛出的错误

*)matplotlib animate中变量作用域的问题

错误提示:

UnboundLocalError: local variable 'i' referenced before assignment

  代码:

i=0
def animate(frameno):

    x = mu + sigma * np.random.randn(N)
    n, _ = np.histogram(x, bins, normed=True)
    time_text.set_text(time_template%frameno)
    i+=1
    for rect, h in zip(patches, n):
        rect.set_height(h)
    return patches

  

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-05-09
  • 2022-01-23
  • 2021-04-06
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-12-25
  • 2021-07-06
  • 2021-05-18
  • 2022-12-23
  • 2021-09-14
相关资源
相似解决方案