[Python]类属性

class Test(object):
    clsAttr = 'as'
    @classmethod
    def clsMethod(cls, attr):
        cls.clsAttr = attr


    @staticmethod
    def getClsAttr():
        Test.clsAttr = 'im-as'
        return Test.clsAttr




print 'Test.clsAttr', Test.clsAttr
Test.getClsAttr()
print 'Test.clsAttr', Test.clsAttr
Test.clsMethod('imas')
print 'Test.clsAttr', Test.clsAttr

猜你喜欢

转载自blog.csdn.net/cn_wk/article/details/80358802
今日推荐