zoukankan      html  css  js  c++  java
  • 3.15作业

    # 2.1:编写用户登录接口
    #1、输入账号密码完成验证,验证通过后输出"登录成功"
    #2、可以登录不同的用户
    #3、同一账号输错三次锁定,(提示:锁定的用户存入文件中,这样才能保证程序关闭后,该用户仍然被锁定)
    # 开始新建 lock.txt user.txt
    # import time
    # count=0
    # while count<3:
    # inp_name=input('请输入用户名:')
    # inp_pwd=input('请输入密码:')
    # with open("user.txt",mode="rt",encoding="utf-8") as f,open("lock.txt",mode="rt",encoding="utf-8") as f2:
    # for line in f:
    # username,password=line.strip().split(':')
    # for lock in f2:
    # res=lock.strip()
    # if inp_name==res:
    # print('{}该账户已锁定'.format(res))
    # time.sleep(5)
    # elif inp_name==username and inp_pwd==password:
    # print('登陆成功')
    # break
    # else:
    # print('登录失败')
    # count+=1
    # if count==3:
    # with open("lock.txt",mode="at",encoding="utf-8") as f2:
    # res=f2.write(inp_name)
    # time.sleep(5)
    # count=0


    # 2.2:编写程序实现用户注册后,可以登录,
    # 提示:
    while True:
    msg = """
    0 退出
    1 登录
    2 注册
    """
    print(msg)
    cmd = input('请输入命令编号>>: ').strip()
    if not cmd.isdigit():
    print('必须输入命令编号的数字,傻叉')
    continue

    if cmd == '0':
    break
    elif cmd == '1':
    # 登录功能代码(附加:可以把之前的循环嵌套,三次输错退出引入过来)
    pass
    elif cmd == '2':
    # 注册功能代码
    pass
    else:
    print('输入的命令不存在')

    # 思考:上述这个if分支的功能否使用其他更为优美地方式实现
    没想出来。。。
  • 相关阅读:
    数据库权限分配操作
    1130-host ... is not allowed to connect to this MySql server
    ubuntu 14.04安装mysql-python
    Ubuntu中的MySQL修改root密码的多种方法
    ubuntu下安装mysql及卸载mysql方法
    XShell本地上传文件到Ubuntu上及从Ubuntu下载文件到本地
    深度学习-1
    html-新闻滚动条
    Django部署uwsgi 与 nginx配置
    二叉树层次遍历
  • 原文地址:https://www.cnblogs.com/chenyoupan/p/12500167.html
Copyright © 2011-2022 走看看