Python 2.7 在python中使用多个分隔符解析文本文件

Python 2.7 在python中使用多个分隔符解析文本文件,python-2.7,parsing,string-parsing,Python 2.7,Parsing,String Parsing,我是python编程新手。我想分割一个有两个分隔符的文本文件 我只是硬编码一行文本文件,以获得正确的逻辑。我想在拆分文本后打印分隔符。不太清楚怎么做 text='+1 This book is awesome. It has been so helpful to be able to go back to track trends. -1 I bought this for my sister and she didn't like it. The note sections t

我是python编程新手。我想分割一个有两个分隔符的文本文件

我只是硬编码一行文本文件,以获得正确的逻辑。我想在拆分文本后打印分隔符。不太清楚怎么做

  text='+1  This book is awesome.  It has been so helpful to be able to go back to track trends.  -1    I bought this for my sister and she didn't like it. The note sections to t'
   for line in text.split('+1'):
      print line
这给了我不带+1的输出,但我想要这样的输出:

+1  This book is awesome.  It has been so helpful to be able to go back to track trends.
-1  I bought this for my sister and she didn't like it. The note sections to t

我该怎么做?感谢您的帮助。谢谢。

查看
查找
字符串的方法:

理解了它的作用后,使用
text.find(“+1”)
text.find(“-1”)

另外:
split
并不像您想象的那样工作。阅读文档(),运行“ab ac bc de”.split(“ab”)
,查看结果并确保了解发生了什么