Python模块学习--property
来源:互联网 发布:支教如何报名 知乎 编辑:程序博客网 时间:2024/06/03 17:23
# -*- coding: utf-8 -*-#创建一个学生类,基本属性id、姓名、年龄class Student(object): def __init__(self,stuId,stuName,stuAge): self.stuId = stuId self.stuName = stuName self.stuAge = stuAge #getter def getStuName(self): return self.stuName #setter def setStuName(self,stuName): self.stuName = stuName #类似C#简单封装 stuProprety = property(getStuName,setStuName)#查找dy同学是否存在def find(stuName): if "dy" == stu.stuProprety: print "find dy" else: print "no such student" if __name__ == '__main__': stu = Student(1,"dy",20) find(stu.stuProprety) print stu.stuProprety stu.stuProprety = "YD" find(stu.stuProprety) print stu.stuPropretyproperty 类似C#的简单封装,级直接可以通过对象对属性进行获取、赋值
0 0
- Python模块学习--property
- python 中的property模块
- python学习笔记 - @property
- python学习笔记 - @property
- python学习-property
- python学习笔记 - @property
- Python 学习笔记property
- python学习03 --@property
- python学习笔记 使用@property
- python学习-模块学习
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python模块学习-os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Oracle Job定时调度
- java反射初学整理
- 啊时代发生大爱的爱上打法
- CSS流体(自适应)布局下宽度分离原则
- 理解linux0.11加载过程
- Python模块学习--property
- 百度地图定位功能的使用v4.2步骤(笔记)
- 设计模式(3):抽象工厂模式
- jQuery EasyUI — 格式化显示datagrid的numberbox编辑类型
- Quick Sort快速排序
- 同步和异步、阻塞和非阻塞的关系
- mina处理断包和粘包
- 利用C#创建一个简单的Windows服务
- jsp运行(承接上一篇)