码迷,mamicode.com
首页 >  
搜索关键字:staticmethod    ( 335个结果
python静态方法和类方法
静态方法是类和类的独立实例。它是在类范围中定义的方法。它可以直接由类和实例被称为。类方法和静态方法都要使用装饰器来定义,定义的基本格式是:@staticmethod def (): #do something类方法定义的基本格式是:@ classmethoddef (cls): #do someth...
分类:编程语言   时间:2015-09-17 11:19:22    阅读次数:150
python 静态方法与类方法
#!/usr/bin/python #-*-coding:utf-8-*- classPizza(object): a="AA" def__init__(self): self.name=‘leon‘ defcook(self): returnself.mix_ingredients(self.cheese,self.vegetables) @staticmethod defmix_ingredients(x,y): printPizza.a #printPizza.name returnx+y @c..
分类:编程语言   时间:2015-09-10 17:37:21    阅读次数:166
Python中的self,cls参数
普通的方法,第一个参数需要是self,它表示一个具体的实例本身。 如果用了staticmethod,那么就可以无视这个self,而将这个方法当成一个普通的函数使用。 而对于classmethod,它的第一个参数不是self,是cls,它表示这个类本身。 >>> class A(object):     def foo1(self):         print "Hello",self...
分类:编程语言   时间:2015-08-15 12:05:32    阅读次数:261
@staticmethod和@classmethod的作用与区别
一般情况,要使用某个类的方法,需要先实例化一个对象再调用方法。而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用。既然@staticmethod和@classmethod都可以直接类名.方法名()来调用,那他们有什么区别呢从它们的使用上来看,-@staticmethod不..
分类:其他好文   时间:2015-08-13 06:34:15    阅读次数:127
@classmethod及@staticmethod方法浅析【python】
目前对于python中@classmethod 类方法和@staticmethod静态方法的有了一定的认识,之后有进一步的认识后继续记录。@classmethod :是和一个class类相关的方法,可以通过类货类实例进行调用,并将该class对象(不是class的实例对象)隐式地当作第一个参数传入。...
分类:编程语言   时间:2015-07-30 00:40:55    阅读次数:135
Python good tutorials
1.@classmethodand@staticmethodhttp://stackoverflow.com/questions/12179271/python-classmethod-and-staticmethod-for-beginner2. yieldhttp://stackoverflow...
分类:编程语言   时间:2015-07-28 07:55:48    阅读次数:138
dbf文件使用python读取程序
使用python读取dbf # -*- coding: utf-8 -*- import struct,csv,datetime class DBF_Operator(): @staticmethod def SHHQ_dbf_reader(f): numrec, lenheader = struct.unpack('<xxxxLH22x', f.read(32))...
分类:数据库   时间:2015-07-04 00:53:06    阅读次数:165
Python 实例方法,类方法和静态方法
普通的方法,第一个参数需要是self,它表示一个具体的实例本身。如果用了staticmethod,那么就可以无视这个self,而将这个方法当成一个普通的函数使用。而对于classmethod,它的第一个参数不是self,是cls,它表示这个类本身。>>> class A(object): de...
分类:编程语言   时间:2015-07-01 17:54:10    阅读次数:120
php之self与parent
self:本类,注意不要理解为本对象 parent:父类 在引用自身的静态属性/静态方法时,以及父类的静态属性/方法时可以用到 用法 self::$StaticProperty self::StaticMethod parent::$StaticProperty parent:...
分类:Web程序   时间:2015-05-27 11:38:06    阅读次数:118
2.7全部内置函数(来自文档)
Built-in Functionsabs()divmod()input()open()staticmethod()all()enumerate()int()ord()str()any()eval()isinstance()pow()sum()basestring()execfile()i...
分类:其他好文   时间:2015-05-24 17:03:13    阅读次数:136
335条   上一页 1 ... 29 30 31 32 33 34 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!