关于python——面向对象开发


类的属性:

#coding:utf-8

class Milo():
    var1 = "类的属性var1"
    __var2 = "类的私有属性_var2"

    def fun(self):
        self.var2 = "对象的公有属性var2"
        self.__var3 = "对象的私有属性_var3"
        var4 = "函数 fun的局部变量var4"

    def other(self):
        print var4
        print self.__var3

zou = Milo()
zou.fun()
zou.other()

你可能感兴趣的:(关于python——面向对象开发)