python 面向对象__call__
来源:互联网 发布:亿商网络 编辑:程序博客网 时间:2024/06/06 04:33
[oracle@node01 0914]$ cat a1.py class Person(object): def __init__(self, name, gender): self.name = name self.gender = gender def query(self,friend): print self.name print self.gender self.friend=friend print self.friend h=Person('aa','bb')h.query('cc')[oracle@node01 0914]$ python a1.py aabbcc[oracle@node01 0914]$ [oracle@node01 0914]$ cat a2.py class Person(object): def __init__(self, name, gender): self.name = name self.gender = gender def __call__(self,friend): print self.name print self.gender self.friend=friend print self.friendp=Person('Bob', 'male')p('Tim')[oracle@node01 0914]$ python a2.py BobmaleTim一个类实例也可以变成一个可调用对象,只需要实现一个特殊方法__call__()。
阅读全文
0 0
- python 面向对象__call__
- python __call__ 可调用对象
- python __call__ (可调用对象)
- python __call__ (可调用对象)
- Python __call__
- python __call__
- Python __call__
- python __call__
- Python __call__
- Python可调用对象__call__方法的用法分析
- python 函数是可调用对象和特殊方法__call__
- python的__call__
- [Python小菜]__call__是什么
- python __call__ 函数
- Python __new__ ,__init__,__call__
- python的__call__
- Python中的__init__,__call__
- Python中的__init__,__call__
- SpringBoot重写addResourceHandlers解决resources下面静态资源无法访问
- [Windosw Erro 1114] 动态链接库(Dll)初始化例程失败
- 2017-09-14
- veloctity
- python 中文字符报错Process finished with exit code 0
- python 面向对象__call__
- Python基础01
- 201512-1数位之和
- android linux编译tensorflow的jar包和so文件
- 浅谈数据分析和数据建模
- 欢迎使用CSDN-markdown编辑器
- ArrayList与LinkedList的区别
- NOIP 2016 Senior 6
- iframe 父子页面之间交互