前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 小程序练习

python 小程序练习

作者头像
程序员同行者
发布2018-06-22 16:33:25
5620
发布2018-06-22 16:33:25
举报
文章被收录于专栏:程序员同行者程序员同行者

还有一些小bug

基本有

输入用户名密码

认证成功后显示欢迎信息

输出三次后锁定

代码语言:javascript
复制
# -*- coding:utf-8 -*-
account_file=('C:\Users\guigu\Desktop\user.txt')
lock_file=('C:\Users\guigu\Desktop\lock.txt')
f = file(account_file)
account_list = f.readlines()
f.close()
while True:
    f = file(lock_file)
    lock_list=[]
    for i in f.readlines():
        line = i.strip('\n')
        lock_list.append(line)
    f.close()
    loginSuccess = False
    username=raw_input("username:").strip()
    if username in lock_list:
        print "sorry,you are already in the block list,get the fuck out!"
        break
    for line in account_list:
        line=line.split()
        if line[0] == username:
            for i in range(3):
                password = raw_input('password:').strip()
                if password == line[1]:
                    print "welcome %s login my system" % username
                    loginSuccess = True
                    break
          
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-12-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档