Python的类
来源:互联网 发布:米维斯s和卡马d1c知乎 编辑:程序博客网 时间:2024/06/15 00:24
Python的类
# coding=utf-8__author__ = 'zyt'class Fruit(): name = None age = 0 def __init__(self): # 自动被调用 self.name = 'apple' self.age = 1 print '类名是', self.__class__.__name__ def set_name(self, nm): self.name = nm def show_name(self): print 'name is:', self.nameif __name__ == '__main__': apple = Fruit() apple.show_name() apple.set_name('Red Fuji Apple') apple.show_name() print type(apple) print isinstance(apple, Fruit)运行结果:类名是 Fruitname is: applename is: Red Fuji Apple<type 'instance'>True
0 0
- Python--day13 python的类
- 【Python】Python学习笔记(类的继承)
- 【Python】Python的类、对象、属性、方法
- Python--day14 python的类2
- [Python]类的基础知识
- Python的类
- Python类的继承
- python的类
- python类的语法
- Python的类
- Python的str类
- [Python]类的基础知识
- python 类的使用
- python 类的使用
- python类的学习
- Python的类
- [Python]类的基础知识
- python类的继承
- oracle时间数据格式的分析
- Makefile总结
- IBM MQ介绍
- 黑马程序员-------反射
- 从json自动生成模型代码
- Python的类
- C语言基础---BOOL 类型,运算符,if 语句,switch语句
- POJ 3168 Barn Expansion(几何啊 )
- IBM MQ 使用指南
- JDBC中将一个变量加入SQL语句执行
- python中共享模块
- django部署
- WebSphere MQ程序设计初探
- jquery get ajax 重复提交的奇怪问题