TypeError: 'module' object is not callable cp fromhttp://blog.csdn.net/huang9012/article/details/17417133
来源:互联网 发布:aws vpn windows 编辑:程序博客网 时间:2024/05/17 06:12
程序代码
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
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
0 0
- TypeError: 'module' object is not callable cp fromhttp://blog.csdn.net/huang9012/article/details/17417133
- 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 的解决方法
- 【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 原因分析
- 【Python】TypeError: 'module' object is not callable 原因分析
- python import 包问题: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 原因分析
- Scrapy
- ubuntu安装spark
- ubuntu安装spark on yarn
- FatMouse的交易问题
- workon在zsh中不起作用
- TypeError: 'module' object is not callable cp fromhttp://blog.csdn.net/huang9012/article/details/17417133
- c++中string类型用下标初始化后str.size()为0 输出string值为空
- sublime text2 ctrl+b出现错误
- c++ 函数调用在进入下一个循环的时候会再次初始化参数,将函数体直接写进去就正常
- strcmp函数的使用
- c语言位域
- ubuntu 14.04 vim install youcompleteme
- 笔试题总结
- 常用正则表达式