Py学习  »  Python

Python在一行中查找单词,并将其附加到一个新的文本文件中

scofx • 3 年前 • 1167 次点击  

我使用jupyter notebook with pandas,我想在一个大文件中找到我选择的一个重复出现的单词,然后选择行并将其粘贴或附加到另一个文本文件中,例如使用单词“ 测验 ".:

this is a test sample line
this is a second example line
this is a third example line
this is a test fourth sample line
this is a final example line

然后在一个新的文本文件中,只显示 测验 “目前:

this is a test sample line
this is a test fourth sample line

我如何在python中使用jupyter实现这一点以使事情变得更简单?

另外,如果你能从多个文本文件中读取并附加行而不覆盖它们,那将是完美的!

一如既往地谢谢你!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129344
 
1167 次点击  
文章 [ 1 ]  |  最新文章 3 年前