复制代码 代码如下:
#!/usr/bin/python
#coding=gbk

class User:
    def __init__(self,username,password,age,sex):
        self.username=username
        self.password=password
        self.age=age
        self.sex=sex

    def tell(self):
        print 'UserContext:Name:%s,Pass:%s,Age:%s,Sex:%s' % (self.username,self.password,self.age,self.sex)

class Member(User):
    def __init__(self,username,password,age,sex,user_id):
        User.__init__(self,username,password,age,sex)
        self.user_id=user_id
        print '(AdminUser:%s)' % self.username

    def tell(self):
        User.tell(self)
        if self.user_id==1:
            print 'This is Administrator!'
        else:
            print 'This is User'

t=Member('admin','123456','18','男',1)
s=Member('jack','2222','19','男','0')

user_member=[t,s]
for m_user in user_member:
    m_user.tell()

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com