简体   繁体   English

Python 读取 Pastebin Raw

[英]Python Reading a Pastebin Raw

Start = 5 #Starts Reading at line 5
End = 10 #Stops Reading at line 10



URL = "https://pastebin.com/raw/"
contents = requests.get(URL).text.split('\n')

this is my current code to reading a pastebin, I was wondering if there was a way where i could start reading at a specific line and stop reading at the second specific line.这是我当前读取 pastebin 的代码,我想知道是否有一种方法可以让我从特定行开始阅读并在第二个特定行停止阅读。

My pastebin looks something this我的 pastebin 看起来像这样

split gives you a list so just slice the list from start to end. split为您提供一个列表,因此只需将列表从头到尾切片。

URL = "https://pastebin.com/raw/"
contents = requests.get(URL).text.split('\n')[start:end]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM