以下内容转自 数析学院,只节选了部分,有需要的同学可以直接查看原文
主要内容包括:
Python 类的基础知识
实现短期利率类
实现现金流序列类
1、Python 类的基础知识
- class ExampleOne(object):
- pass
- c = ExampleOne()
- c.__str__()
- type(c)
- class ExampleTwo(object):
- def __init__(self, a, b):
- self.a = a
- self.b = b
- c = ExampleTwo(1, 'text')
- c.a
- c.b
- c.a = 100
- c.a
- c = ExampleOne()
- c.first_name = 'Jason'
- c.last_name = 'Bourne'
- c.movies = 4
- print c.first_name, c.last_name, c.movies
- class ExampleThree(object):
- def __init__(self, a, b):
- self.a = a
- self.b = b
- def addition(self):
- return self.a + self.b
- c = ExampleThree(10, 15)
- c.addition()
以上内容转自 数析学院,如需完整内容可以直接查看原文


雷达卡




京公网安备 11010802022788号







