python的魔术方法
来源:互联网 发布:unity a 寻路算法 编辑:程序博客网 时间:2024/04/28 22:30
持续更新
类:Example
实例:example = Example()
__str__
描述类的实例 print example
__repr__
描述类 print Example
__call__
调用实例 example() #=Example()()
__setattr__
实例属性赋值
__getattr__
获取实例属性值
class Book(object): def __setattr__(self, name, value): if name == 'value': object.__setattr__(self, name, value - 100) else: object.__setattr__(self, name, value) def __getattr__(self, name): try: return object.__getattribute__(name) except: return name + ' is not found!' def __str__(self): return ' cost : ' + str(self.value)c = Book()c.value = 101print c.value #1print cprint c.Type
__slots__
类所能包含的所有新建属性,继承自object类
0 0
- python的魔术方法
- python所有的魔术方法钩子函数
- Python 魔术方法指南
- Python 魔术方法指南
- python魔术方法
- Python 魔术方法指南
- Python 魔术方法指南
- Python 魔术方法指南
- Python 魔术方法指南
- Python魔术方法
- Python 魔术方法指南
- Python 魔术方法指南
- Python中的魔术方法
- Python 魔术方法指南
- python进阶----魔术方法
- Python魔术方法详解
- python魔术方法详解
- python类:magic魔术方法
- activemq 基本使用案例
- 查看java对象占堆内存多少个字节
- LMDB installation
- 混淆打包(一)
- github入门教程
- python的魔术方法
- PHP 购物车 session (ThinkPHP)
- 网址
- jquery获取select的中值和文本
- 3.CSS中常见属性详解
- cocos2d js v3.10 sprite点击事件的区域问题
- nyoj_16 矩形嵌套
- 使用新的 Android Studio 加速你的开发
- Visual Studio 2013 的 Xamarin 安装教程