我执行了以下任务,根据分隔符的多次出现来分割文件。
我有一个包含以下数据的文件:
Number of Employees - 95
==============================================================================
Telephone Number - 972123111111
Empl Name - David
Designation - Software Engineer
Address: **********
Doamin: Python
==============================================================================
Telephone Number - 972123111112
Empl Name - Glen
Designation - Software Engineer
Doamin: Python
==============================================================================
Telephone Number - 972123111111
Empl Name - Jhon
Designation - Software Engineer
Address: **********
Doamin: Python
==============================================================================
在这个文件中,我想将每个员工的信息拆分为“=”,然后打印所有员工的内容,如下所示:
Details of Employee: (Employee Name)
Telephone Number: (employee telephone number)
Designation : (employee desgination)
我已经编写了将文件中的数据提取到变量中的代码,并使用下面的正则表达式对数据进行灰色化,但没有效果:
re.findall('[^=]=*.*?[=*$]', a)
使用^{} 而不是
re.findall()
,如下所示:试试这个片段,它将所有员工数据作为字典存储在一个完整的列表中
相关问题 更多 >
编程相关推荐