day1:作业 编写登录接口并画出相应的流程图

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了day1:作业 编写登录接口并画出相应的流程图相关的知识,希望对你有一定的参考价值。

作业要求:

1.输入用户名密码

2.认证成功后显示欢迎信息

3.输错三次后锁定

代码如下

_user_list =[]
_user_dict = {}
_login_error_count = 0
while True:
    user_naming = input(Plass input your name :)
    user_password = input(Plass input your password:)
    user_data = open(UserPassWord)
    for _user_data in user_data:
        user_datas = _user_data.strip()
        user_list = user_datas.split(,)
        users_name = user_list[0].strip()
        users_password = user_list[1].strip()
        users_lock = user_list[2].strip()
        users_error = int(user_list[3].strip())
        _user_dict[users_name] = {name:users_name,password:users_password,lockcount:users_lock,errorcount:users_error}
    user_data.close()
    if user_naming in _user_dict.keys():
        if _user_dict[user_naming][lockcount] == 1 :
            print(you have been locked)
            break
        if user_naming == _user_dict[user_naming][name] and user_password == _user_dict[user_naming][password]:
            print(welcome to enter the system )
            break
        else:
            _user_dict[user_naming][errorcount] += 1
            if  _user_dict[user_naming][errorcount]  <  3 :
                print(the password was wrong,plase try again!)
                write_data = open(UserPassWord,w+)
                for user_value in _user_dict.values():
                    _user_list = [user_value[name],user_value[password],str(user_value[lockcount]),str(user_value[errorcount])]
                    _users_list = ,.join(_user_list)
                    write_data.write(_users_list+\\n)
                write_data.close()
            else:
                print(your name have locked!)
                write_data = open(UserPassWord,w+)
                _user_dict[user_naming][lockcount] = 1
                _user_dict[user_naming][errorcount] = 0
                for user_value in _user_dict.values():
                    _user_list = [user_value[name],user_value[password],str(user_value[lockcount]),str(user_value[errorcount])]
                    _users_list = ,.join(_user_list)
                    write_data.write(_users_list+\\n)
                write_data.close()
    else:
        print(your password was wrong!)
        _login_error_count += 1
        if _login_error_count > 2:
            break

流程图:

技术分享

 

以上是关于day1:作业 编写登录接口并画出相应的流程图的主要内容,如果未能解决你的问题,请参考以下文章

day1作业:编写登录窗口一个文件实现

Day1作业---登录接口及多级菜单

day1作业:登录接口

day1 作业编写登录窗口

day1作业登录接口总结

分析超市购物流程,并画出活动图