TypeError: 'module' object is not callable 原因分析
class Person:
#constructor
def __init__(self,name,sex):
self.Name = name
self.Sex = sex
def ToString(self):
return 'Name:'+self.Name+',Sex:'+self.Sex
在IDLE中报错:
>>> import Person
>>> per = Person('dnawo','man')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
per = Person('dnawo','man')
TypeError: 'module' object is not callable
原因分析:
Python导入模块的方法有两种:import module 和 from module import,区别是前者所有导入的东西使用时需加上模块名的限定,而后者不要。
正确的代码:
>>> import Person
>>> person = Person.Person('dnawo','man')
>>> print person.Name
或
>>> from Person import *
>>> person = Person('dnawo','man')
>>> print person.Name
转载于:https://www.cnblogs.com/kungfupanda/archive/2012/08/09/2630784.html
TypeError: 'module' object is not callable 原因分析相关推荐
- TypeError: 'module' object is not callable 原因分析(python模块导入注意事项)
程序代码 class Person: #constructor def __init__(self,name,sex): self.Name = name ...
- 菜尼奥排错之merge6 = merge([drop4,up6], mode = ‘concat‘...)TypeError: ‘module‘ object is not callable
环境版本: Ubuntu 18.04.2 LTS Nvidia GeForce RTX2080super CUDA Version 10.0 tensorflow-gpu 1.13.1 keras 2 ...
- python import 错误 TypeError: 'module' object is not callable
python import 错误 TypeError: 'module' object is not callable 在这里,有 Person.py test.py; 在 test.py 里面 im ...
- Running pipenv gives TypeError: 'module' object is not callable
Running pipenv gives TypeError: 'module' object is not callable 记一次项目使用pipenv安装虚拟环境遇到的问题 导致上述报错的原因: ...
- Python 3.8+moviepy报错:TypeError: ‘module‘ object is not callable
☞ ░ 老猿Python博文目录:https://blog.csdn.net/LaoYuanPython ░ 一.引言 最近有博友在博文< https://blog.csdn.net/LaoYu ...
- Python导入模块(包)的两种方式 TypeError: 'module' object is not callable
Python编程时明明在开始处import了相关包,但是调用函数时就报错如下: TypeError: 'module' object is not callable Python中有两种导入包(模块, ...
- TypeError: 'module' object is not callable (pytorch在进行MNIST数据集预览时出现的错误)
在使用pytorch在对MNIST数据集进行预览时,出现了TypeError: 'module' object is not callable的错误: 上报错信息图如下: 从图中可以看出,报错位置为第 ...
- 自动化测试PyCharm运行后提示:TypeError: ‘module‘ object is not callable
如图所示:我运行PyCharm时提示:TypeError: 'module' object is not callable 第一点根据异常提示发现 line 10, in driver = webdr ...
- python TypeError: ‘module‘ object is not callable
这个问题一般是使用import 的时候模块没有导入问题引起的,所以你需要检查下导入的模块了 例如我的这个提示如下 提示 random.random() 提示这个地方出现了问题 代码如下 感觉也没有问题 ...
最新文章
- 211高校导师:我到底想要什么样的研究生?
- python opencv 图像膨胀
- python读写excel数据--pandas
- 上传文件显示进度条_【技巧 】iOSamp;Windows互传文件?透过「文件」轻松解决~...
- 2017.9.27 青蛙的约会 失败总结
- log4j mysql 单引号_log4j写数据库存在单引号问题
- 修改树状控件TreeCtrl的节点名称
- 以太坊2.0存款合约地址余额已突破50万ETH
- 数字后端基本概念介绍<Blockage Link>
- 新冠病毒到底对患者的肺做了什么?康复者会像SARS一样出现肺纤维化吗?
- python中空字符串是什么_python为空怎么表示 python如何判断字符串为空
- APM时代的质量保障之路:腾讯互娱品质管理部性能负责人访谈
- MyEclipse中如何修改项目的编码格式
- 激活Windows Server 2003 2008终端授权服务器
- m3u8简单教程之巨齿鲨下载
- 鸟哥的linux私房菜学习笔记《二十》bash简介
- The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from
- codeforces#1166F. Vicky's Delivery (Service并查集+启发式合并)
- [华中科技计组实验]logisim完成单周期5级流水MIPS CPU
- 增大VirtualBox虚拟硬盘容量
热门文章
- JForum 的 SSO集成
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Myeclipse 10 利用工具生成网络服务接口并调用
- Network | UDP checksum
- C++内存管理学习堆和栈
- 怎么修改Outlook2010 PST数据文件位置(默认邮件存储目录)
- Jquery UI dialog 详解 (中文)
- 张家界a货翡翠,酒泉a货翡翠
- Vue+DataTables warning:table id=xxxx -Cannot reinitialize DataTable.报错解决方法
- WAF Bypass数据库特性(Mysql探索篇)