简体   繁体   English

Python错误:TypeError:“模块”对象不可调用

[英]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.

相关问题 python fbprophet错误,TypeError:“模块”对象不可调用 - python fbprophet error, TypeError: 'module' object is not callable python3 中的错误(TypeError: 'module' object is not callable) - Error in python3 (TypeError: 'module' object is not callable) ggplot Python:错误:TypeError:“模块”对象不可调用 - ggplot Python : Error : TypeError: 'module' object is not callable Python typeerror&#39;module&#39;对象不可调用 - Python typeerror 'module' object is not callable TypeError:“模块”对象在python中不可调用 - TypeError: 'module' object is not callable in python Python TypeError:“模块”对象不可调用 - Python TypeError: 'module' object is not callable 类型错误:“模块”对象在 Python 3 中不可调用 - TypeError: 'module' object is not callable in Python 3 类型错误:“模块”object 不可调用(在 python 中) - TypeError: 'module' object is not callable (in python) Python错误:TypeError:&#39;模块&#39;对象不能为HeadFirst Python代码调用 - Python error: TypeError: 'module' object is not callable for HeadFirst Python code TypeError:使用Selenium ChromeDriver Chrome和Python时,&#39;module&#39;对象无法调用错误 - TypeError: 'module' object is not callable error using Selenium ChromeDriver Chrome with Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM