Home > Backend Development > Python Tutorial > Python 用户登录验证的小例子

Python 用户登录验证的小例子

WBOY
Release: 2016-06-16 08:46:42
Original
995 people have browsed it

复制代码 代码如下:

#!/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()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template