Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I got a result from BeautifulSoup, but instead of printing all links, I want to print the first three links:
BeautifulSoup
for link in links and i in range(3): print link
Which is not correct. What should I do in this case?
只需对列表进行切片,以便您仅获得前三个元素:
for link in links[:3]: print link
你不需要循环。简直了print links[:3]。
print links[:3]
编辑。另见 sberry 的评论