当前位置: 首页 > news >正文

网站建设步骤电脑微博推广

网站建设步骤电脑,微博推广,贸易公司网站设计,权威发布型舆情回应以什么为主前言 #源码见文末公众号哈# 登录系统 一个简单的登录系统包含了登录账户、注册账户、修改密码以及注销账户的操作。 1. 登录账户 登录系统主要需要判断账户是否存在,不存在就注册一个账户,如果第一次登录系统,我们需要先新建一个文件&…

前言

#源码见文末公众号哈#

登录系统 

一个简单的登录系统包含了登录账户、注册账户、修改密码以及注销账户的操作。

1. 登录账户

登录系统主要需要判断账户是否存在,不存在就注册一个账户,如果第一次登录系统,我们需要先新建一个文件,保存管理员的账户以及密码,具体代码如下:

def user_login():
    user_name=name.get()
    user_key=key.get()
    try:
        with open('d:\\user.pickle','rb') as user_file:
            user_info=pickle.load(user_file)
    except FileNotFoundError:
        with open('d:\\user.pickle','wb') as user_file:
            user_info={'admin':'12345'}
            pickle.dump(user_info,user_file)
            user_file.close()
    if user_name in user_info:
        if user_key == user_info[user_name]:
            tkinter.messagebox.showinfo(title='提示', message='登录成功!' )
        else:
            tkinter.messagebox.showerror('提示','密码错误!请重新输入')
    else:  
        exist = tkinter.messagebox.askyesno('提示','该用户名未注册,是否立即注册?')
        if exist:
            user_sign()

2. 注册账户 

注册账户时需要判断该账户是否存在,如果已经存在时提醒用户重新注册即可。

注册时还要输入两次密码,判断是否一致。 

具体代码如下:

def user_sign():
    sign_root=tk.Toplevel(root)
    sign_root.title('注册账户')
    screenheight=sign_root.winfo_screenheight()
    screenwidth=sign_root.winfo_screenwidth()
    h=220
    w=300
    x=(screenwidth-w)//2
    y=(screenheight-h)//2
    sign_root.geometry("%dx%d+%d+%d"%(w,h,x,y))
    new_name=tk.StringVar()
    tk.Label(sign_root,text='欢迎来到注册系统',font=('宋体',20),bg='white',fg='red',width=20,height=1).place(x=7,y=10)
    tk.Label(sign_root,text='新的账户',font=('宋体',12)).place(x=20,y=60)
    entry_name=tk.Entry(sign_root,textvariable=new_name,font=('宋体',12),show=None).place(x=100,y=60)
    new_key=tk.StringVar()
    tk.Label(sign_root,text='新的密码',font=('宋体',12)).place(x=20,y=100)
    entry_key=tk.Entry(sign_root,textvariable=new_key,font=('宋体',12),show='*').place(x=100,y=100)
    same_key=tk.StringVar()
    tk.Label(sign_root,text='请确认密码',font=('宋体',12)).place(x=10,y=140)
    entry_keys=tk.Entry(sign_root,textvariable=same_key,font=('宋体',12),show='*').place(x=100,y=140)
    def sign_check():
        name=new_name.get()
        key1=new_key.get()
        key2=same_key.get()
        with open('d:\\user.pickle','rb') as user_file:
            user_info=pickle.load(user_file)
            user_file.close()
        if name in user_info:
            tkinter.messagebox.showerror('提示','该账户已存在!')
        elif key1!=key2:
            tkinter.messagebox.showerror('提示','两次输入密码不一致,请重新输入!')
        else:
            user_info[name]=key1
            with open(r'd:\\user.pickle','wb') as user_file:
                pickle.dump(user_info,user_file)
                user_file.close()
            tkinter.messagebox.showinfo('提示','注册成功!')
            sign_root.destroy()
    tk.Button(sign_root,text='注册',font=('宋体',12),bg='red',fg='white',width=5,height=1,command=sign_check).place(x=130,y=180)    

3. 修改密码

修改密码时需要先确定需要修改密码的账户是否存在,不存在无法修改密码。

修改密码时如果账户存在,还要判断原密码是否一致以及新输入的两次密码是否一致。

具体源码如下:

def user_change():
    change_root=tk.Toplevel(root)
    old_name=tk.StringVar()
    old_key=tk.StringVar()
    new_key=tk.StringVar()
    same_key=tk.StringVar()
    change_root.title('修改密码')
    screenheight=change_root.winfo_screenheight()
    screenwidth=change_root.winfo_screenwidth()
    h=220
    w=300
    x=(screenwidth-w)//2
    y=(screenheight-h)//2
    change_root.geometry("%dx%d+%d+%d"%(w,h,x,y))
    tk.Label(change_root,text='欢迎来到修改密码系统',font=('宋体',20),bg='white',fg='green',width=20,height=1).place(x=5,y=10)
    tk.Label(change_root,text='请输入你的账号',font=('宋体',12),width=15,height=1).place(x=5,y=60)
    tk.Entry(change_root,textvariable=old_name,show=None).place(x=130,y=60)
    tk.Label(change_root,text='请输入原始密码',font=('宋体',12),width=15,height=1).place(x=5,y=90)
    tk.Entry(change_root,textvariable=old_key,show=None).place(x=130,y=90)
    tk.Label(change_root,text='请输入修改密码',font=('宋体',12),width=15,height=1).place(x=5,y=120)
    tk.Entry(change_root,textvariable=new_key,show='*').place(x=130,y=120)
    tk.Label(change_root,text='请确认你的密码',font=('宋体',12),width=15,height=1).place(x=5,y=150)
    tk.Entry(change_root,textvariable=same_key,show='*').place(x=130,y=150)
    def change_check():
        name=old_name.get()
        key1=old_key.get()
        key2=new_key.get()
        key3=same_key.get()
        with open("d:\\user.pickle",'rb') as user_file:
            user_info=pickle.load(user_file)
            user_file.close()
        if name in user_info:
            if key1==user_info[name]:
                if key2==key3:
                    user_info[name]=key2
                    with open('d:\\user.pickle','wb') as user_file:
                        pickle.dump(user_info,user_file)
                        user_file.close()
                    tkinter.messagebox.showinfo('提示',"修改成功!")
                    change_root.destroy()
                else:
                    tkinter.messagebox.showerror('提示','两次密码不一致,请重新输入!')
            else:
                tkinter.messagebox.showerror('提示','密码错误,请重新输入!')
        else:
            exist=tkinter.messagebox.askyesno('提示','该账户不存在,是否立即注册账户?')
            if exist:
                user_sign()      
    tk.Button(change_root,text='修改',font=('宋体',12),bg='green',fg='white',command=change_check).place(x=130,y=180) 

4. 注销账户

注销账户时需要先判断账户是否存在,然后输入两次原密码,当输入的两次原密码相同时即可注销

成功。

具体代码如下:

def user_del():
    old_name=tk.StringVar()
    old_key=tk.StringVar()
    same_key=tk.StringVar()
    del_root=tk.Toplevel(root)
    del_root.title('注销账户')
    screenheight=del_root.winfo_screenheight()
    screenwidth=del_root.winfo_screenwidth()
    h=220
    w=300
    x=(screenwidth-w)//2
    y=(screenheight-h)//2
    del_root.geometry("%dx%d+%d+%d"%(w,h,x,y))
    tk.Label(del_root,text='欢迎来到注销账户系统',font=('宋体',20),bg='white',fg='black',width=20,height=1).place(x=5,y=10)
    tk.Label(del_root,text='请输入你的账号',font=('宋体',12),width=15,height=1).place(x=5,y=60)
    tk.Entry(del_root,textvariable=old_name,show=None).place(x=130,y=60)
    tk.Label(del_root,text='请输入原始密码',font=('宋体',12),width=15,height=1).place(x=5,y=100)
    tk.Entry(del_root,textvariable=old_key,show=None).place(x=130,y=100)
    tk.Label(del_root,text='请确认你的密码',font=('宋体',12),width=15,height=1).place(x=5,y=140)
    tk.Entry(del_root,textvariable=same_key,show='*').place(x=130,y=140)    
    def del_check():
        name=old_name.get()
        key1=old_key.get()
        key2=same_key.get()
        with open('d:\\user.pickle','rb') as user_file:
            user_info=pickle.load(user_file)
            user_file.close()
        if name in user_info:
            if key1==key2:
                if key1==user_info[name]:
                    user_info.pop(name)
                    with open('d:\\user.pickle','wb') as user_file:
                        pickle.dump(user_info,user_file)
                        user_file.close()
                    tkinter.messagebox.showinfo('提示','注销成功!')
                else:
                    tkinter.messagebox.showerror('提示','密码错误!')
            else:
                tkinter.messagebox.showerror('提示','两次密码不一致!')
        else:
            exist=tkinter.messagebox.askyesno('提示','该账户不存在,是否立即注册?')
            if exist:
                user_sign()
    tk.Button(del_root,text='注销',font=('宋体',12),bg='black',fg='white',command=del_check).place(x=130,y=180)  

http://www.shuangfujiaoyu.com/news/34941.html

相关文章:

  • seo优化案例app优化网站
  • 设计素材网站会员哪个最好微网站
  • 手工制作香囊热狗seo优化外包
  • wordpress英文版语言包谷歌seo工具
  • 哪个网站有做车库门的搜狗识图
  • 企业建网站的目的青岛网站建设与设计制作
  • 网站开发vsc网站开发公司网络工程师培训一般多少钱
  • 手机微信网站建设应用商店搜索优化
  • 旅游营销型网站seo网站介绍
  • 网站url结构阳西网站seo
  • 做网站赚钱吗 怎么赚钱页优化软件
  • 如何做简单的网站热门推广软件
  • 海南爱心扶贫网站是哪个公司做的百度下载安装免费版
  • 怎么做日本钓鱼网站排名网站
  • 利用html5 监控网站性能重庆网络推广专员
  • 网站建设的费用和预算市场调研报告模板
  • 网站模块数据同步一网信息一个简单便捷的新闻网站
  • 做网站的时候表格怎么去掉百度指数怎么看地域数据
  • 中央两学一做专题网站济南网络优化厂家
  • 中建卓越建设管理有限公司网站超级软文网
  • 互联网站备案信息微信软文范例100字
  • 南开网站建设搜索引擎推广的方法有
  • 什么网站可以做ppt百度投诉电话人工客服24小时
  • 深圳自适应网站开发经典软文广告案例
  • 做网站域名需要在哪里备案seo简单速排名软件
  • 网站开发与建设会计分录杭州优化seo公司
  • 网页是网站的什么颜色好看网站策划书案例
  • 点匠网站开发流程东莞seo网站排名优化
  • 兰州做网站的公司semifinal
  • 大连网站建设报价优质商家网站注册页面