Python 用户登录验证的小例子

yipeiwu_com6年前Python基础

复制代码 代码如下:

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

相关文章

Python金融数据可视化汇总

Python金融数据可视化汇总

通过本篇内容给大家介绍一下Python实现金融数据可视化中两列数据的提取、分别画、双坐标轴、双图、两种不同的图等代码写法和思路总结。 import matplotlib as mpl...

Python利用sqlacodegen自动生成ORM实体类示例

本文实例讲述了Python利用sqlacodegen自动生成ORM实体类。分享给大家供大家参考,具体如下: 在前面一篇《Python流行ORM框架sqlalchemy安装与使用》我们是手...

python3下使用cv2.imwrite存储带有中文路径图片的方法

由于imwrite前使用编码在python3中已经不适用,可用imencode代替,以下代码是从视频中获取第2帧保存在中文文件夹下的实例: cap = cv2.VideoCaptur...

python实现在函数图像上添加文字和标注的方法

python实现在函数图像上添加文字和标注的方法

如下所示: import matplotlib.pyplot as plt import numpy as np from matplotlib import font_manage...

解决torch.autograd.backward中的参数问题

解决torch.autograd.backward中的参数问题

torch.autograd.backward(variables, grad_variables=None, retain_graph=None, create_graph=False...