码迷,mamicode.com
首页 > 编程语言 > 详细

Python-登录

时间:2020-03-28 18:18:37      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:users   res   imp   with open   账户   NPU   日期   password   spl   

import time

with open(user.txt) as fr:
    result = fr.read()
users = {}
if result:
    all_user_pwd = result.split(\n)
    for i in all_user_pwd:
        user = i.split(,)[0]
        pwd = i.split(,)[-1]
        users[user]=pwd
while True:
    username = input(请输入账号:).lower().strip()
    password = input(请输入密码:).strip()
    if username == ‘‘ and password == ‘‘:
        print(不能为空)
    elif username in users:
        if password==users.get(username):
            print(%s登录成功,今天的日期是%s % (username, time.strftime(%Y-%m-%d %H:%M:%S)))
            break
        else:
            print(密码不对)
    else:
        print(账户不存在)

 

Python-登录

标签:users   res   imp   with open   账户   NPU   日期   password   spl   

原文地址:https://www.cnblogs.com/brf-test/p/12588346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!