我想知道Python2.7中是否有一种方法可以通读文本文档以查找某些单词,然后如果找到这些单词,它将向下阅读几行以查找新词。如果找不到新单词,它将返回查找第一个单词。在
例如,我的文本文档如下所示:
1.Section
2. Cheesecake
3. 0
4. 0
5. 0
6. Tastes good
7. 0
8. 0
9. Donut
10. 0
11. Tastes good
12. 0
13. Cheesecake
14. 0
15. 0
16. Tastes bad
这是我目前掌握的代码:
^{pr2}$从现在开始我不知道该怎么办!我怎样才能让它搜索奶酪蛋糕,然后检查它们是否好吃?在
您还可以将记录从一个关键字分组到下一个关键字。
您可以在行迭代器中使用类似
thisline=line.next()
你也可以继续读你的主循环中的行,比如
试着沿着这些思路。。。。在
相关问题 更多 >
编程相关推荐