zoukankan      html  css  js  c++  java
  • 校园管理系统 -- 登录部分

    版本一:登录之后自动识别身份
     1 def login():
     2     while 1:
     3         name = input('请输入用户名:')
     4         password = input('请输入密码:')
     5         with open('校园成员信息.txt',encoding='utf-8') as info:
     6             for line in info:
     7                 if line.strip().split(' ')[1] == name and line.strip().split(' ')[2] == password:
     8                     print('登录成功')
     9                     return '欢迎{}'.format(line.split(' ')[0])
    10                     break
    11             if line.strip().split(' ')[1] != name:
    12                 print('用户名不存在,请重新输入')
    13                 continue
    14             elif line.strip().split(' ')[2] != password:
    15                 print('密码输入错误,请重新输入')
    16                 continue
    17             break
    18 print(login())
    版本二:先确定身份,再登录
     1 def login():
     2     ID_choise = input('''请选择你的身份
     3     1. 管理员
     4     2. 讲师
     5     3. 学生
     6     ''')
     7     if ID_choise == '1':
     8         open_file = '管理员信息.txt'
     9     elif ID_choise == '2':
    10         open_file = '讲师信息.txt'
    11     elif ID_choise == '3':
    12         open_file = '学生信息.txt'
    13     else:
    14         return '请选择正确的身份'
    15     while 1:
    16         name = input('请输入用户名:')
    17         password = input('请输入密码:')
    18         with open(open_file,encoding='utf-8') as info:
    19             for line in info:
    20                 if line.strip().split(' ')[1] == name and line.strip().split(' ')[2] == password:
    21                     print('登录成功')
    22                     return '欢迎{}'.format(line.split(' ')[0])
    23                     break
    24             if line.strip().split(' ')[1] != name:
    25                 print('用户名不存在,请重新输入')
    26                 continue
    27             elif line.strip().split(' ')[2] != password:
    28                 print('密码输入错误,请重新输入')
    29                 continue
    30             break
    31 print(login())
    
    
  • 相关阅读:
    AC日记——Little Elephant and Numbers codeforces 221b
    AC日记——Little Elephant and Function codeforces 221a
    AC日记——Mice and Holes codeforces 797f
    AC日记——Sliding Window poj 2823
    Poj 2976 Dropping tests(01分数规划 牛顿迭代)
    Bzoj 1968: [Ahoi2005]COMMON 约数研究
    洛谷 P2424 约数和
    Hdu Can you find it?(二分答案)
    SPOJ GSS1
    Bzoj 2243: [SDOI2011]染色(树链剖分+线段树)
  • 原文地址:https://www.cnblogs.com/lpgit/p/9393374.html
Copyright © 2011-2022 走看看