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 的评论
我正在将一个旧的 krufty 应用程序升级到 Rails 3.1。该公司一直在使用 RSpec 和 Capybara 进行验收测试。我们有一些验收测试spec/acceptance失败,并显示以下消息:
spec/acceptance
Failure/Error: get @url NoMethodErr