python中的静态类与方法
来源:互联网 发布:linux下载mysql的命令 编辑:程序博客网 时间:2024/05/22 04:51
觉得语法啥限制的没有java严格,静态方法python的语法默认是这样子的:
@staticmethod def s(): pass
其实你把cls加进来就能调用静态变量,把self加进来就能调用自己的变量了,看看混乱的代码吧,其实对理解也有好处,静态变量和类变量的名字都一样。amazing
class TestClassMethod: def __init__(self): TestClassMethod.s=3; self.s=2 def add(self,cls): self.s=self.s+1; @classmethod def anotheradd(cls,self): cls.s=s.s+1 @staticmethod def otheradd(self,cls): print "as",self.s TestClassMethod.s=TestClassMethod.s+1 @staticmethod def s(): passs=TestClassMethod()s.anotheradd(s)TestClassMethod.anotheradd(s)TestClassMethod.otheradd(s,TestClassMethod)print s.sprint TestClassMethod.s
0 0
- python中的静态类与方法
- python中的类方法与静态方法的区别
- PYTHON中的静态方法和类方法
- python中的静态方法和类方法
- PYTHON中的静态方法和类方法
- python中的静态方法、类方法解读
- python中的静态方法和类方法
- python中的静态方法和类方法
- Python中的类方法和静态方法
- python中的类方法和静态方法
- python中的类方法和静态方法
- python中的静态方法和类方法
- python 中的静态方法
- python中的静态属性,静态方法、类方法解读
- [总结]python 静态方法与类方法
- python 静态方法与类方法
- Python类成员方法与静态方法
- Python中的类方法和静态
- PHP学习总结(11)——PHP入门篇之WAMPServer多站点配置
- Codeforces Round #361 (Div. 2) B. Mike and Shortcuts
- 几种数值积分方法
- NOI 模拟试题(一)
- perl调用命令包含正则表达式,要注意转义符。[经验,还未证实]
- python中的静态类与方法
- 第35个python程序:分支和函数
- (android高仿系列)今日头条 --新闻阅读器 (二)
- 一个聚合的加解密工具类
- mysq数据从一个数据库的表复制到另一个数据库的表
- windows7中安装jdk1.8
- redis学习笔记
- IOS自动布局之Autoresizing
- linux下find(文件查找)命令的用法总结