首页 > 解决方案 > python处理文本文件中的特定部分

问题描述

我有 3 个包含 4 个部分的文件(示例)

File 1                          File 2                    File 3

Section 1                       Section 1                 Section 1
----------                      ----------                ----------
Data 1                          Data 1                    Data 1



Section 2                       Section 2                 Section 2
----------                      ----------                ----------
Data 2                          Data 2                    Data 2



Section 3                       Section 3                 Section 3         
----------                      ----------                ----------
Data 3                          Data 3                    Data 3



Section 4                       Section 4                 Section 4 
----------                      ----------                ----------
Data 4                          Data 4                    Data 4

我只想将第 2 节附加到新文件中。任何想法如何做到这一点?

Output:
NewFile
Data 2 Of File 1
Data 2 Of File 2
Data 2 Of File 3
etc... (If I have more files)

谢谢你

标签: python-3.x

解决方案


推荐阅读