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()

















  • 相关阅读:
    win10 uwp 依赖属性
    win10 uwp 依赖属性
    Java实现蓝桥杯VIP 算法训练 阶乘末尾
    PHP fileperms() 函数
    PHP fileowner() 函数
    PHP filemtime() 函数
    PHP fileinode() 函数
    PHP filegroup() 函数
    查看MySQL已经运行的时长
    [HNOI2016]矿区
  • 原文地址:https://www.cnblogs.com/jack2017/p/7270509.html
Copyright © 2011-2022 走看看