• 校园管理系统 -- 登录部分


    版本一:登录之后自动识别身份
     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())
    
    
  • 相关阅读:
    ZooKeeper基本原理
    Ubuntu上部署C# 网站 步骤简单记录
    代码生成助手
    微信授权封装,欢迎使用
    c#微信开发,使用JS-SDK自定义分享功能,分享朋友圈,分享给朋友等
    ab.exe使用
    【分享·微信支付】 C# MVC 微信支付教程系列之公众号支付
    SVN服务器搭建(一)
    MVC四大筛选器—ActionFilter&ResultedFilter
    MySQL参数化查询的IN 和 LIKE
  • 原文地址:https://www.cnblogs.com/lpgit/p/9393374.html
Copyright © 2020-2023  润新知