python中__str__, __call__方法
来源:互联网 发布:音乐效果器软件 编辑:程序博客网 时间:2024/06/05 02:00
call在加上()时执行
class Foo: def __init__(self): pass def __call__(self, *args, **kwargs): print "__call__"obj = Foo()obj() #自动执行此方法__call__
输出 print ‘对象’ 自动调用str方法
class Foo: def __init__(self): pass def __call__(self, *args, **kwargs): print "__call__" def __str__(self): return "C Class"obj = Foo()print obj #调用__str__方法
0 0
- python中__str__, __call__方法
- python __str__,__repr__,__call__()
- 理解python中的__str__, __call__, __init__, __getattr__
- python的__call__方法
- 关于python __call__() 方法
- python中的__call__方法
- python __call__类方法
- python中 __call__
- python __str__和format方法
- python 特殊方法之__call__()
- python中 __str__和__repr__
- Python中__str__和__repr__
- python中__init__,__call__学习
- Python中__call__用法实例
- python 的特殊方法 __str__和__repr__
- python 的特殊方法 __str__和__repr__
- [笔记]Python class中的__call__()方法
- Python class中的__call__()方法
- Sunday算法---简单高效的字符串匹配算法
- 循环结构、控制跳转、方法
- java去除字符串中的空格、回车、换行符、制表符
- python超级简单爬虫
- osg3.2.1+vs2010+win7编译方法
- python中__str__, __call__方法
- leetcode -- LRU Cache -- 重点
- Day2-差不多写完了。
- c语言之基础-2
- LA 3902 网络
- 快速排序
- Apache HttpClient
- PostgreSQL行列变换
- Redis学习笔记