「Python」- module object is not callable

内容简介

处理TypeError: 'module' object is not callable错误。

问题描述

运行脚本产生TypeError: 'module' object is not callable错误。

问题原因

没有区分清除“模块名”与“类名”。模块名是模块名,类名是类名,二者是有所区别的。

import时,导入的是类名,而不是模块名,应该是import <module_name>.<class_name>或者from <module_name> import <class_name>的形式,而单独引入模块(import <module_name>)是不可以的,模块不可以调用。

解决办法

修改导入语句,引入类名。

参考文献

TypeError: ‘module’ object is not callable