Modify Personal Information Programs:
Save more individual's personal information in a file, as follows:
username password age position department
alex abc123 24 Engineer IT
rain df2@423 25 Teacher Teching
……
1, enter the user name and password, log into the system correctly, print
1. Modify Personal Information
2. Print Personal information
3. Change Password
2, each option to write a method
3, the wrong three times to exit the program at login
def change_info(pinfolist): s = '1.年龄\n2.职务\n3.部门' while True: print(s) choice = int(input('choose please:')) if choice <= 3 and choice >=1 : new_info = input('new information:') pinfolist[choice + 1] = new_info save(pinfolist) else: break def print_info(pinfolist): for value in pinfolist: print(value,end=',') print('') def change_pwd(pinfolist): new_pwd = input('new password:') pinfolist[1] = new_pwd save(pinfolist) def save(pinfolist): file_data = '' new_str = ','.join(pinfolist) with open('人员信息.txt','r') as f: for line in f: if pinfolist[0] in line: line = new_str file_data += line with open('人员信息.txt','w') as f: f.write(file_data) def user_register(name,pwd): f = open('人员信息.txt','r') while True: text_line = f.readline() if text_line: if text_line.find(name) != -1 and text_line.find(pwd) != -1: infolist = text_line.split(',') f.close() return infolist else: break f.close() return None count = 0 while True: while count < 3: username_in = input("用户名:") userpwd_in = input("密码:" ) Personal_info_list = user_register (username_in, userpwd_in) IF personal_info_list == None: COUNT + 1 = Print ( ' name or password error, the INPUT Again ..... ' ) the Continue the else : Print ( ' successful login ..... .... ' ) s_choice = ' 1. modify personal information \ n2 print personal information \ n3 Change password \ n4 Log... ' the while True: Print (s_choice) USER_CHOICEInt = (INPUT ( ' the Choose you want: ' )) IF USER_CHOICE ==. 1 : change_info (personal_info_list) elif USER_CHOICE == 2 : print_info (personal_info_list) elif USER_CHOICE ==. 3 : change_pwd (personal_info_list) the else : BREAK BREAK IF COUNT = 3 = : Print ( ' has been entered incorrectly three times, Log ..... ' ) BREAK