Python 属性错误:';模块';对象没有属性索引

Python 属性错误:';模块';对象没有属性索引,python,function,import,lucene,attributeerror,Python,Function,Import,Lucene,Attributeerror,我试图在另一个python脚本中使用某个pythonnews\u Lucene.py脚本的所有函数。我在我的procescocontinued.py中导入了以下结构的news\u Lucene.py 新闻的代码\u Lucene(): 在procescocontinuous.py中,我正在尝试以下操作: from engines.extras.download_datos_desambiguar import news_Lucene news_Lucene().indexing() 我也试过

我试图在另一个python脚本中使用某个python
news\u Lucene.py
脚本的所有函数。我在我的
procescocontinued.py
中导入了以下结构的
news\u Lucene.py

新闻的代码\u Lucene()

procescocontinuous.py
中,我正在尝试以下操作:

from engines.extras.download_datos_desambiguar import news_Lucene

news_Lucene().indexing()
我也试过了

索引()

但它仍然不起作用。它说
AttributeError:“module”对象没有属性索引
。我做错了什么?

您导入了模块,而不是模块中包含的类对象

使用:

或导入类:

from engines.extras.download_datos_desambiguar.news_Lucene import news_Lucene
建议在模块名中只使用带下划线的小写字符,在类名中使用CamelCase;这有助于避免混淆模块和类

要遵守样式指南,请重命名模块和类;模块名可以是
news\u lucene
,类名可以是
NewsLucene


我注意到整个类只包含静态方法。如果这是该类的唯一目的,则需要完全删除该类。只需将所有内容都设置为顶级函数即可。Python不是Java,如果对您手头的问题没有意义,您根本不需要使用类。

谢谢!但是你能告诉我应该怎么做才能同时调用类
news\u Lucene()
的所有函数吗?不要逐个调用它?@kaushaya:创建一个调用其他函数的函数?在我的
news\u Lucene()
代码中,
f3()
调用
f2()
。因此,如果我只调用
f3()
它是否能够访问
f2()
?@kaushaya:模块中的函数可以访问同一模块中的所有其他函数。静态方法之外还有一些代码。我如何访问它?
news_Lucene.news_Lucene().indexing()
from engines.extras.download_datos_desambiguar.news_Lucene import news_Lucene