[英]Python Error: TypeError: 'module' object is not callable
I have written the simplest python code (module) : 我写了最简单的python代码(模块):
def newplus(x, y):
return x*y
This is stored in a folder sabya (which is my package). 这存储在文件夹sabya(这是我的包裹)中。 The folder has
_init_
and newplus.py
files. 该文件夹具有
_init_
和newplus.py
文件。
In my IDLE I can open the module sabya.newplus
. 在我的IDLE中,我可以打开模块
sabya.newplus
。 When I give import sabya.newplus
there is no error. 当我
import sabya.newplus
,没有错误。 but when I issue : 但是当我发出:
>>> sabya.newplus(2, 3)
I am getting this error 我收到此错误
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
sabya.newplus(2, 3)
TypeError: 'module' object is not callable
您需要对功能进行如下限定:
sabya.newplus.newplus(2, 3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.