实现python的: __init__ , __sub__方法,__init___sub_,class Number
实现python的: __init__ , __sub__方法,__init___sub_,class Number
class Number: def __init__(self, start): # on Number(start) self.data = start def __sub__(self, other): # on instance - other return Number(self.data - other) # result is a new instanceX = Number(5) # Number.__init__(X, 5)Y = X - 2 # Number.__sub__(X, 2)print Y.data # Y is new Number instance
相关内容
- python多态,重写父类方法,python多态重写,def rotate_t
- Python获得进程内存使用量的脚本,python获得进程脚本
- python 以可读并且可写方式打开文件,python打开文件,w
- python操作符重写,实现+操作符,python操作符,import str
- Instance Objects,instanceobjects,class Comple
- python中的虚函数,python函数,class Super:
- python代码注释,python注释,# a commenti
- python构造函数,,# def __i
- 输出对象属性,输出对象,class SayMyN
- python实现ftp传输,pythonftp传输,import ftpli
评论关闭