Day1: Write A Job logon interface and draw the corresponding flowchart. day1 Flowchart

Source: Internet
Author: User

Day1: Write A Job logon interface and draw the corresponding flowchart. day1 Flowchart

Job Requirements:

1. Enter the user name and password

2. The welcome information is displayed after the authentication is successful.

3. Lock after three wrong attempts

The Code is as follows:

_user_list =[]_user_dict = {}_login_error_count = 0while 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

Flowchart:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.