![](/img/trans.png)
[英]How to delete one line before a specific word in a text file in python
[英]How do I delete all text before a specific word?
txt1_response = requests.get("http://www.gutenberg.org/cache/epub/11313/pg11313.txt")
txt1 = txt1_response.text
我已经阅读了该网址的所有文本。 我想删除“关于动物”一词之前的所有文本内容。
做这个的最好方式是什么?
txt1 [txt1.index('ABOUT ANIMALS'):]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.