员工信息表-装逼版
Posted quegai18
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了员工信息表-装逼版相关的知识,希望对你有一定的参考价值。
import os file_name = ‘员工信息表‘ noun_list = [‘staff_id‘, ‘name‘, ‘age‘, ‘phone‘, ‘dept‘, ‘enroll_date‘] def file_operation(file): ‘‘‘ 先进行文件操作,把文件内容加载到内存,以方便调用的形式储存文件信息 :param file_name: :return: ‘‘‘ file_info = open(file, ‘r‘, encoding=‘utf-8‘) data_dic = {‘staff_id‘: [], ‘name‘: [], ‘age‘: [], ‘phone‘: [], ‘dept‘: [], ‘enroll_date‘: []} for line in file_info: info_id, info_name, info_age, info_tel, info_dept,info_time=line.split(‘,‘) # 按照上述的顺序依次把信息存入value的空列表中 data_dic[‘staff_id‘].append(info_id) data_dic[‘name‘].append(info_name) data_dic[‘age‘].append(info_age) data_dic[‘phone‘].append(info_tel) data_dic[‘dept‘].append(info_dept) data_dic[‘enroll_date‘].append(info_time) file_info.close() return data_dic def file_save(): f = open(‘临时存放‘,‘w‘,encoding=‘UTF-8‘) for id_index, id in enumerate(data[‘staff_id‘]): info_list = [] for noun in noun_list: info_list.append(data[noun][id_index]) f.write(‘,‘.join(info_list)) f.close() os.replace(‘临时存放‘,file_name) def catch_order(): #获取用户指令 # step:1 while True: user_order = input(‘请输入指令: ---> ‘).strip() # 交互第一步,让用户输入指令,首尾去空格 if not user_order: continue input_order(user_order) # 把用户指令传入(指令分析)的函数 # 2 def print_login(msg,login_type=‘info‘): if login_type == ‘info‘: print(‘