easygui开发模拟注册登陆系统 [ 可直接复制粘贴+运行 ]

easygui是一套简单的图形GUI库,大家通过pip安装一下就好了。
easygui的内容挺多博文都有写过,这里我推荐 [张老师的小黑屋的教程]
(https://www.cnblogs.com/scios/p/8832227.html)
嗯。好了,因为这个项目需要两个文件,我们可以新建一个文件夹,下面存放着我们的main.py和usr_pwd.txt。
usr_pwd用来存储用户的用户名与密码。

from easygui import *

user_data = open('usn_pwd.txt', 'r+')
user_own_data = user_data.read().split('\n')
users = dict()
# print(user_own_data)
for i in user_own_data:
    try:
        users.setdefault(i.split(maxsplit=1)[0], i.split(maxsplit=1)[1])
    except IndexError:
        continue
# print(users)
sign_in_or_sign_up = buttonbox(msg='Do you want to Sign up or Sign in?',
                               choices=['Sign Up', 'Sign In'])
if sign_in_or_sign_up == 'Sign Up':
    while True:
        info = multpasswordbox(msg='Input basic information here',
                               title='basic information', fields=['username', 'password'],
                               run=True)
        # print(info)
        try:
            if info[0].strip() and info[1].strip():
                if not info[0] in list(users.keys()):
                    user_data.write(info[0] + " " + info[1] + "\n")
                    msgbox(msg='Signed Up successfully!')
                    break
                else:
                    msgbox(msg='This user name has been registered!')
            else:
                msgbox(msg='Please input the user name and password!')
        except TypeError:
            msgbox('Exited!')
            break

elif sign_in_or_sign_up == 'Sign In':
    info = multpasswordbox(msg='Input username and password here',
                           title='Sign In',
                           fields=['username', 'password'], run=True)
    if info[0] in users.keys():
        pass
    else:
        msgbox('用户不存在!')



好嘞,没咯!


12岁小学生被迫营业,原创不易,求打赏:)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值