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: