[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
posted @ 2018-05-18 00:27  cn_wk  阅读(45)  评论(0)    收藏  举报