zoukankan      html  css  js  c++  java
  • python第一天作业:用户登陆

    作业二:编写登陆接口

    • 输入用户名密码
    • 认证成功后显示欢迎信息
    • 输错三次后锁定

    #!/usr/bin/env python3


    import sys
    account_file = 'a.txt'
    locked_file = 'b.txt'

    def deny_account(username):
    print("user is locked!")
    with open(locked_file,'a+') as lff:
    lff.readlines(username,' ')

    def main():
    try_count = 0
    try_limit = 3
    while try_count < try_limit:
    username = input("pls input your name:")
    with open(locked_file,'r') as lf:
    for line in lf.readlines():
    if len(line) == 0:
    continue
    if username == line.strip():
    sys.exit("your user %s is out" % username)
    if len(username) == 0:
    print("not allow empty!")
    continue
    password = input("pls input password:")
    with open(account_file,'r') as af:
    flag = False
    for line in af.readlines():
    user,passwd = line.strip().split()
    if username == user and password == passwd :
    flag =True
    print("succes!")
    break
    if flag == False:
    if try_count <2:
    print("user or passwd error!")
    try_count +=1
    else:
    print("welcome")
    break

    else:
    deny_account(username)

    if __name__ == '__main__':
    main()

















  • 相关阅读:
    2015 12 04课堂随便
    java 循环制作三角形
    2015 12 3课堂随笔
    张王李相亲应用if else
    2015 12 01 课堂笔记。 运算符的使用
    Java图形化界面设计——布局管理器之null布局(空布局)
    jQuery
    jQuery
    jQuery
    jQuery
  • 原文地址:https://www.cnblogs.com/jack2017/p/7270509.html
Copyright © 2011-2022 走看看