我正在尝试编写一组 Python 类,这些类将查询数据库以检索一些值,然后构建一个网络图。问题是每当我尝试调用我的类之一的构造函数时,我都会收到此错误 相关代码如下
class NetworkConstructor:
def __init__(self):
self.nodes=dict()
self.queryservice=QueryService()
self.graph=networkx.Graph()
QueryService 类的相关位是
def __init__(self):
self.connect()
def connect(self):
self.conn=MySQLdb.Connect(host="xxx", port=3306,user="xxx",passwd="xxx",db="xxx")
self.cursor=self.conn.cursor()
我也导入了所有必需的库
最佳答案
看起来您的 QueryService 类位于同名的模块中。尝试一下
self.queryservice=QueryService.QueryService()
关于python - 如何解决 Python 类型错误 : 'module' object is not callable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10666233/