Python入门的36个例子 之 29 -> OOP – 创建一个类
2009-09-12 14:54
771 查看
源代码下载:下载地址在这里
output:
22
Hello!
# 033 class Person: age = 22 def sayHello(self): # 方法与函数的区别在于需要一个self参数 print 'Hello!' # end of def # end of class # 这是我良好的编程风格 p = Person() print p.age p.sayHello()
output:
22
Hello!
相关文章推荐
- Python入门的36个例子 之 32 -> OOP – Inheritance 继承
- Python入门的36个例子 之 35 -> try – 一个使用的例子
- Python入门的36个例子 之 30 -> OOP – 初始化
- Python入门的36个例子 之 31 -> OOP – 属于类的变量和属于对象的变量
- Python入门的36个例子 之 23 -> Objects and References —— 复制引用还是复制实体对象
- Python入门的36个例子 之 33 -> try – 异常是不可避免的,关键是怎样处理
- Python入门的36个例子 之 24 -> 再说说String
- Python入门的36个例子 之 34 -> Raise An Error – 自定义异常信息
- Python入门的36个例子 之 25 -> Console In File Out
- Python入门的36个例子 之 18 -> Modules —— 将它们放到不同的文件里
- Python入门的36个例子 之 26 -> File In Console Out
- Python入门的36个例子 之 36 -> finally
- Python入门的36个例子 之 19 -> List
- Python入门的36个例子 之 27 -> Add Something Into A File
- Python入门的36个例子 之 19 -> Tuple(元素组)
- Python入门的36个例子 之 28 -> Pickle —— 利用文件存储对象
- Python入门的36个例子 之 21 -> Dictionary —— 通过你的ID找到你
- Python入门的36个例子 之 22 -> Sequences —— 统一的访问方式以及负索引
- struts2入门-第一个例子==》第一个struts2实例——HelloWorld==》Struts2.0搭建和简单实例==>写一个Steuts2的经典入门案例,做了一个登陆程序作为入门例子
- Unreal Engin_Maya插件ArtV1_001<初认Artv1创建一个带绑定的人物&&对其进行简单的设置>