小编D00*_*07a的帖子

调用方法和访问属性之间的区别

我是Python的新手,我使用的是Python 3.3.1.

class Parent: # define parent class 
    parentAttr = 100
    age = 55

    def __init__(self): 
        print ("Calling parent constructor") 

    def setAttr(self, attr): 
        Parent.parentAttr = attr 

class Child(Parent):
    def childMethod(self):
        print ('Calling child method')
Run Code Online (Sandbox Code Playgroud)

现在我要创造

c=child
c.[here every thing will appear methods and attr (age,setAttr)]
Run Code Online (Sandbox Code Playgroud)

我怎样才能区分方法和属性?我的意思是,我什么时候使用c.SetAtrr(Argument), c.SetAtrr=value

python oop

6
推荐指数
1
解决办法
5251
查看次数

标签 统计

oop ×1

python ×1