发布时间:2019-08-18 09:20:55编辑:auto阅读(2035)
一:为什么要使用python的类对象编程?
我的理解:
1:便于维护、扩展代码。
2:更易于重复使用代码。
二:python 类对象编程代码如下:
#创建firstClass类
class firstClass:
i=10
#定义hello方法,注意:python 的类方法必须传一个self参数
def hello(self):
#必须通过self来访问类变量
for m in range(0,self.i):
print m
#创建类实例test
test=firstClass()
#通过实例调用方法
test.hello()
上一篇: 构建 编译和运行Urho3D工程
下一篇: H3C MSTP、RSTP案例配置
50987
50372
40985
37853
32316
29209
28093
22921
22890
21218
1083°
1771°
1446°
1380°
1655°
1467°
2124°
3681°
3618°
2540°