Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python错误:TypeError:';模块';对象不可调用_Python_Python 3.x - Fatal编程技术网

Python错误:TypeError:';模块';对象不可调用

Python错误:TypeError:';模块';对象不可调用,python,python-3.x,Python,Python 3.x,我已经编写了最简单的python代码(模块): 这是存储在一个文件夹sabya(这是我的包)。该文件夹具有\u init\uuu和newplus.py文件 在空闲状态下,我可以打开模块sabya.newplus。当我给出import sabya.newplus时,没有错误。但当我发布: >>> sabya.newplus(2, 3) 我得到了这个错误 Traceback (most recent call last): File "<pyshell#15>

我已经编写了最简单的python代码(模块):

这是存储在一个文件夹sabya(这是我的包)。该文件夹具有
\u init\uuu
newplus.py
文件

在空闲状态下,我可以打开模块
sabya.newplus
。当我给出
import sabya.newplus
时,没有错误。但当我发布:

>>> sabya.newplus(2, 3)
我得到了这个错误

   Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    sabya.newplus(2, 3)
TypeError: 'module' object is not callable
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
萨比亚·新加(2,3)
TypeError:“模块”对象不可调用

您需要按照以下要求对函数进行限定:

sabya.newplus.newplus(2, 3)

您需要对函数进行以下限定:

sabya.newplus.newplus(2, 3)

请注意,
“\u init”!=”__初始化。
。请注意
“\u初始化”!=”__初始化
。非常感谢。成功了。我是Python新手。今天是我第一次学习Python,所以我一点也没学。我认为它的工作方式是sabya是包(目录),newplus是模块(.py文件),其中newplus是函数。因此,我的函数必须限定为package.module.function\u name。我说的对吗?另一种导入方式:
从sayba.newplus导入newplus
,然后调用
newplus(2,3)
。再次感谢。我在newplus.py文件中添加了另一个函数hello(str)并称为sabya.newplus.hello('test')。成功了。谢谢你帮我理解这个概念。非常感谢。成功了。我是Python新手。今天是我第一次学习Python,所以我一点也没学。我认为它的工作方式是sabya是包(目录),newplus是模块(.py文件),其中newplus是函数。因此,我的函数必须限定为package.module.function\u name。我说的对吗?另一种导入方式:
从sayba.newplus导入newplus
,然后调用
newplus(2,3)
。再次感谢。我在newplus.py文件中添加了另一个函数hello(str)并称为sabya.newplus.hello('test')。成功了。谢谢你帮助我理解这个概念。