0
点赞
收藏
分享

微信扫一扫

python中函数与类 类中的方法-静态方法/动态方法

龙驹书房 2023-05-09 阅读 71

class student():
    position='即令'
    def __init__(self,name,age):
        self.name=name
        self.age=age
    def eat(self):
        pass
    @classmethod
    def cla(cls):
        pass
    @staticmethod
    def sta():
        pass
    pass

stu=student(name='张三',age='12')
print(stu.position)

stu.sta()
stu.cla()

# 直接使用静态和类方法
student.cla()
student.sta()

# 动态邦参

def show():
    pass
stu.show=show
stu.show()


 

举报

相关推荐

0 条评论