ImportError:没有名为error的模块

时间:2018-03-02 06:17:02

标签: python python-2.7 numerical-methods bisection

在Python工程中的数值方法,第2版,作者:Jaan Kiusalaas,我写了第146页的相同模块,它使用二分法计算根,f(x)= 0:

1

我遇到以下错误:

  

ImportError Traceback(最近一次调用最后一次)   execfile中的/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc(fname,* where)       173其他:       174 filename = fname    - > 175 内置 .execfile(文件名,* where)

     

/home/uwhpsc/Desktop/bisection2/bisection2.py in()         1来自数学导入日志,ceil   ----> 2导入错误         3         4 def bisection2(f,x1,x2,switch = 0,tol = 1.0e-9):         5 f1 = f(x1)

     

ImportError:没有名为error

的模块

请有人可以告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

要使此代码生效,您可以删除以下行:

import error

在线上说:

if f1*f2 > 0.0: error.err('Root is not bracketed')

将其更改为:

if f1*f2 > 0.0: quit('Root is not bracketed')
相关问题