1. @classmethod

class ClassMethod:
def __init__(self, func):
self.func = func def __get__(self, instance, owner):
"""
类来调用,instance为None,owner为类本身。
实例来调用,instance为实例,owner为类本身。
:param instance:
:param owner:
:return:
""" def feedback(*args, **kwargs):
return self.func(owner, *args, **kwargs) return feedback class People:
name = 'edward' @ClassMethod
def say_hi(cls, msg):
print(f'你好{cls.name},{msg}') People.say_hi('你好帅')

2. @staticmethod

class StaticMethod:
def __init__(self, func):
self.func = func def __get__(self, instance, owner):
def feedback(*args, **kwargs):
return self.func(*args, **kwargs) return feedback class People:
name = 'edward' @StaticMethod
def say_hi(x, y, z): # say_hi = StaticMethod(say_hi)
print('------>', x, y, z) People.say_hi(1, 2, 3)

最新文章

  1. Hibernate插入数据后获得ID
  2. flex Vector
  3. jmeter jdbc request使用详解
  4. Win7安装visual c++ 2015 redistributable x64失败
  5. scala 学习笔记(04) OOP(上)主从构造器/私有属性/伴生对象(单例静态类)/apply方法/嵌套类
  6. Win7系统中提示:本地无法启动MySQL服务,报的错误:1067,进程意外终止的解决方法。
  7. C#读取物理网卡信息及其对应的IP地址
  8. Pass value from child popup window to parent page window using JavaScript--reference
  9. 10个最有用的 IntelliJ IDEA 插件
  10. 微信团队分享:Kotlin渐被认可,Android版微信的技术尝鲜之旅
  11. Prepare paddle in Docker
  12. EditText获取焦点
  13. DVWA的安装
  14. 关于ARM NEON学习的一些资料
  15. RN(八)——react-native-image-viewer & react-native-swiper
  16. Spring框架的事务管理的基本概念
  17. ubuntu下配置JDK7环境变量
  18. nginx的简单使用和使用nginx在windows上搭建tomcat集群
  19. SonarQube Scanner execution execution Error --- Failed to upload report - 500: An error has occurred. Please contact your administrator
  20. Puppet全面详解

热门文章

  1. 《nginx 一》dns解析 nginx安装
  2. java 中的阻塞队列
  3. SpringBoot | 第十二章:RabbitMQ的集成和使用
  4. wcf问题集锦
  5. agc015E - Mr.Aoki Incubator(dp)
  6. 将vim配置成一个轻量的IDE开发工具
  7. CPU保护模式DPL、CPL简易理解
  8. Android自定义控件练手——简单的时钟
  9. 跨平台移动开发phonegap/cordova 3.3全系列教程-开发环境搭建
  10. Neo4j-3.0.3 (Debian 8)