OOP

class Worker(object):
    def __init__(self,name,bu,score,sex,age):
        self.__name = name
        self.__bu = bu
        self.__score = score
        self.__sex =sex
        self.__age =age
    def print_allinfo(self):
        print "Name:%s,Bu:%s,Score:%s,Sex:%s,Age:%s " %(self.__name,self.__bu,self.__score,self.__sex,self.__age)
    def get_name(self):
        return self.__name
    def get_score(self):
        return self.__score
    def get_age(self):
        return self.__age
    def set_score(self,score):
        self.__score = score
    def set_age(self,age):
        self.__age = age

__XXX 不能访问

非要访问的话_类名__XXX

posted on 2016-10-27 15:35  chinxfin  阅读(123)  评论(0编辑  收藏  举报

导航