其他分享
首页 > 其他分享> > 实验七

实验七

作者:互联网

class user:
    def __init__(self,name='guest',password=111111,status=1):
        self.name=name
        self.password=password
        self.status=status
    def info(self):
        if self.status==1:
            print(f'用户名:{self.name},密码:{self.password},账号状态正常')
        else:
            print(f'用户名:{self.name},密码:{self.password},账号处于封禁状态')
    def modify_password(self):
        for i in range(3):
            x=eval(input('输入旧密码'))
            if x==self.password:
                self.password=eval(input('输入新密码'))
                print('密码修改成功')
                break
            else:
                print('密码错误')
                if i==2:
                    print('账号已锁,请稍后再试')
class admin(user):
    def __init__(self,name='admin',password=999999,status=1):
        self.name=name
        self.password=password
        self.status=status
    def reset_password(self,user):
        user.password=eval(input('输入新密码'))
    def ban_user(self,user):
        user.status=0
    def unlock_user(self,user):
        user.status=1
u1=user()
u1.info()
u1.modify_password()
a1=admin()
a1.info()
a1.reset_password(u1)
a1.ban_user(u1)
print(u1.status)
a1.unlock_user(u1)
print(u1.status)

 

标签:status,name,self,u1,实验,user,password
来源: https://www.cnblogs.com/ljb202183360049/p/16353477.html