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
  • 相关阅读:
    HTML常用标签
    消息机制JMS
    一个Socket连接管理池(心跳机制)
    Java调用其他程序时waitFor()阻塞
    JDBC连接数据库
    mysql入门
    WebService到底是什么
    Netty详解
    Mongodb集群搭建
    JavaScript入门
  • 原文地址:https://www.cnblogs.com/guigujun/p/6122720.html
Copyright © 2011-2022 走看看