|
|
第1行: |
第1行: |
| =Classmethod是什么鬼=
| |
| <pre>
| |
| cat classmeth.py
| |
| #!/usr/bin/python
| |
| # -*- coding: utf-8 -*-
| |
|
| |
| class A(object):
| |
| bar = 1
| |
| def func1(self):
| |
| print ('foo')
| |
| @classmethod
| |
| def func2(cls):
| |
| print ('func2')
| |
| print (cls.bar)
| |
| cls().func1() # 调用 foo 方法
| |
|
| |
| A.func2() # 不需要实例化
| |
| evan@latop:~/python//pytest$ python classmeth.py
| |
| func2
| |
| 1
| |
| foo
| |
|
| |
|
| | =downloads= |
| | https://clonezilla.org/downloads.php |
|
| |
|
| | https://clonezilla.org/downloads/download.php?branch=stable |
|
| |
|
| evan@latop:~/python/py2018/pytest$ cat 2meth.py
| |
| #!/usr/bin/python
| |
| # -*- coding: utf-8 -*-
| |
|
| |
| class A(object):
| |
| bar = 'love'
| |
| def func1(self):
| |
| print ('2love')
| |
| @classmethod
| |
| def func2(cls):
| |
| print ('func2')
| |
| print (cls.bar)
| |
| cls().func1() # 调用 foo 方法
| |
|
| |
| A.func2() # 不需要实例化
| |
|
| |
|
| python 2meth.py
| | 好像记得linux256有个教程呢 |
| func2
| |
| love
| |
| 2love
| |
| | |
| </pre>
| |
|
| |
|
| =see also= | | =see also= |
| [http://www.runoob.com/python/python-func-classmethod.html Python classmethod 修饰符] | | [http://blog.51cto.com/storysky/291587 用"再生龙"Clonezilla 来克隆Linux系统] |
|
| |
|
| [https://blog.csdn.net/handsomekang/article/details/9615239 python - @staticmethod和@classmethod的作用与区别] | | [https://blog.csdn.net/jiangwei0512/article/details/73692007 Clonezilla使用指南] |
|
| |
|
| https://realpython.com/instance-class-and-static-methods-demystified/ | | https://www.howtoing.com/linux-centos-ubuntu-disk-cloning-backup-using-clonezilla |
|
| |
|
| [[category:python]] | | [https://www.cnblogs.com/EasonJim/p/7616614.html Linux系统备份还原工具3(使用Clonezilla/再生龙对硬盘进行镜像和克隆,类似于Ghost)] |
| | [[category:ops]] |
2019年10月14日 (一) 13:48的最新版本