随笔分类 - python
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.csdn.net/yyt8yyt8/article/details/7030416#http://zhidao.baidu.com/link?url=zdkLDmHXmSqFlGp7uBWr...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://www.bubuko.com/infodetail-313791.html#类的专有方法(__del__)'PS:析构函数只需要明白其用途,目前无需深入学习'#__init__#作用:当一个类实例删除...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://www.cnblogs.com/zyxstar2003/archive/2011/03/21/1989954.html#类的专有方法(__init__)#__init__,类似于构造函数#作用:初始化...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.chinaunix.net/uid-22521242-id-4081674.html'''#类的方法 共有方法 私有方法 类方法 静态方法静态方法是属于类的,一般方法...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.chinaunix.net/uid-22521242-id-4081674.html#一个关于类的案例class People(): #定义基本属性 name='' age...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.chinaunix.net/uid-22521242-id-4081674.html'''#类的方法 共有方法 私有方法 类方法 静态方法'''class MyCla...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.itpub.net/26250550/viewspace-1411768/#私有属性的另类访问方式#这里利用的好像是一种伪私有的机制class MyClass(): def __ini...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.csdn.net/wklken/article/details/6313265#获取类所有属性和查看帮助文档class MyClass(): def __init__(self...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.csdn.net/wklken/article/details/6313265#类的私有属性及私方法(请注意属性的传值方式)class MyClass(): def __ini...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.csdn.net/wklken/article/details/6313265#类的私有属性及私方法class MyClass(): def __init__(self,nam...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#http://blog.csdn.net/wklken/article/details/6313265#类的定义'''class : '''class MyClass(): def __init...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#怎么区分类变量和实例变量?#实例变量:在变量前面添加了self,就是实例变量,比如:self.name(完整定义为:属于实例私有,对实例变量的操作不会影响到其他的实例对象)#类变量:不添加前缀self,就是类变量(...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#面向对象编程案例04--访问控制#如果要让内部属性不被外部所访问,怎么做?#在属性的名称前加上两个下划线__即可,在python中,实例变量名下面如果加上__开头,就变成了一个私有变量private#只有内部可以访...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#file:BaseModelTest.py #模块名class BaseClass(): def __init__(self,name,age): self.name=name s...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#面向对象编程案例02--显示地调用父类的__init__()'''继承是面向对象的重要特征之一,继承是2个类或多个类之间的父子关系,子类继承父类的所有共有实例变量和方法。继承实现了代码的重用,减少代码的编写量pyt...
阅读全文
摘要:# -*- coding: utf-8 -*-#python 27#xiaodeng#面向对象编程案例01class Behave(): def __init__(self,name): self.name=name def once(self): print...
阅读全文
摘要:1 # -*- coding: cp936 -*- 2 #xiaodeng 3 #python 27 4 5 #什么叫迭代 6 #如果给定一个list/tuple,可以通过for循环遍历出来,这种遍历我们称之为迭代 7 8 #案例3:可迭代对象 9 s=[i for i in [1,2,3]]...
阅读全文

浙公网安备 33010602011771号