TypeError: 'module' object is not callable 原因分析
来源:互联网 发布:php 用户权限 编辑:程序博客网 时间:2024/06/03 06:42
程序代码
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 Personperson = Person.Person('dnawo','man') print person.Name
或
from Person import * person = Person('dnawo','man') print person.Name
0 0
- 【Python】TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- 【Python】TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- 【Python】TypeError: 'module' object is not callable 原因分析
- 【python系列】TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- 【Python】TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析
- 【Python】TypeError: 'module' object is not callable 原因分析
- TypeError: 'module' object is not callable 原因分析(python模块导入注意事项)
- TypeError: 'module' object is not callable
- TypeError: 'module' object is not callable
- 【caffe源码研究】第三章:源码篇(1) :caffe整体架构
- 高并发读与高并发写的项目总结和mongodb使用中遇到的坑
- 数据结构之递归(Recursion)------分而治之
- 实现一个仿华为天气的进度圆
- Swift 之 UIProgressView
- TypeError: 'module' object is not callable 原因分析
- Manifest值冲突解决方法
- FFmpeg编译.so
- Nodejs + mongoDB 使用初体验
- ConcurrentHashMap解释
- delphi第一个程序
- setsid使用
- 欢迎使用CSDN-markdown编辑器
- LSH-局部敏感哈希在k-NN算法中的应用