zoukankan      html  css  js  c++  java
  • python 小程序练习

    还有一些小bug

    基本有

    输入用户名密码

    认证成功后显示欢迎信息

    输出三次后锁定

    # -*- coding:utf-8 -*-
    account_file=('C:UsersguiguDesktopuser.txt')
    lock_file=('C:UsersguiguDesktoplock.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('
    ')
            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
              

              else:
                print "password error"


    else: f =file(lock_file,'a') f.write('%s ' %username) f.close() print "entered,3 times of wrong passwd,going to lock %s" % username if loginSuccess == True:break if loginSuccess == True:break
  • 相关阅读:
    safeNet
    网店
    微信公众号自定义菜单与回车
    西游记对教育的启发
    zencart资源
    cmd批处理常用符号详解
    div垂直居中
    git工作量统计
    VS2012变化的快捷键:
    sql 树 递归
  • 原文地址:https://www.cnblogs.com/guigujun/p/6122720.html
Copyright © 2011-2022 走看看