zoukankan      html  css  js  c++  java
  • 登录界面

    while 1:
        username =input ('请输入你的注册账号:')
        userkey = input('请输入你的注册密码(只能是纯数字):')
        if userkey.isdigit():
            with open('数据存储','r+',encoding='utf-8') as f:
                f.write('{} 
     {}'.format(username,userkey))
            print("注册成功")
            break
        else:
            print('请输入数字')
    i = []
    l = 0
    while l < 3:
        user = input('请输入账号:')
        key1 = input('请输入密码:')
        with open('数据存储','r+',encoding='utf-8') as f:
                for line in  f:
                    i.append(line)
                    print(i)
                    if user == i[0].strip() and key1 == i[1].strip():
                            print("登录成功")
                            break
                    else:
                        print('登陆失败')
                        print('你还有{}次机会'.format(l))
                    l += 1
    View Code

    这个代码有问题,嗯.

    不知为何,usrkey不能添加进入列表

    待修改

    修改完成

    原因:将if循环列入了for循环中,导致每次只输入一个元素进入列表中

    while 1:
        username =input ('请输入你的注册账号:')
        userkey = input('请输入你的注册密码(只能是纯数字):')
        if userkey.isdigit():
            with open('数据存储','r+',encoding='utf-8') as f:
                f.write('{} 
     {}'.format(username,userkey))
            print("注册成功")
            break
        else:
            print('请输入数字')
    i = []
    l = 0
    while l < 3:
        user = input('请输入账号:')
        key1 = input('请输入密码:')
        with open('数据存储','r+',encoding='utf-8') as f:
                for yihang in  f:
                    i.append(yihang)
                    print(i)
        if user == i[0].strip() and key1 == i[1].strip():
                print("登录成功")
                break
        else:
                    print('登陆失败')
                    print('你还有{}次机会'.format(l))
                    l += 1
    View Code
  • 相关阅读:
    SQL Server连接Oracle详细步骤
    SQLServer2012连接mysql5.5
    SQL Server的链接服务器技术
    2键盘录入Scanner
    1标识符
    电脑从新分盘(软件)
    Tomcat安装配置
    windows下安装和配置多个版本的JDK
    Myeclipse2014的安装
    Could not find acceptable representation
  • 原文地址:https://www.cnblogs.com/zly9527/p/11257206.html
Copyright © 2011-2022 走看看