所以我有一个结构如下的文本文件:
Product ID List:
ABB:
578SH8
EFC025
EFC967
CNC:
HDJ834
HSLA87
...
...
这个文件继续,许多公司的名字和Id在他们下面。然后我需要得到所选公司的ID,并将它们附加到一个列表中,在那里它们将用于搜索网站。以下是我要获取数据的当前行:
^{pr2}$如果只有一家公司的产品标识,而没有文本,这很好用。这不适用于我的计划,然而。。。我如何让读者从(一个例子)读到下一个公司之前?我在想也许可以在文件中添加一些东西,比如ABB END
来知道要剪切到哪里,但是我仍然不知道如何首先在行之间剪切。。。如果你能让我知道,那太好了!在
两个连续的换行符充当分隔符,因此只需在那里拆分一个数据字典:
由于文件的结构是这样的,您可以按照以下步骤操作:
\n\n
拆分成一个列表\n
另外,看一下regular expressions来解析这样的数据。在
相关问题 更多 >
编程相关推荐