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.
直接循环遍历findAll结果:
findAll
for elem in res.findAll('a'): print elem
该.find()方法只返回它找到的第一个元素res,它不会从您找到的最后一个命中继续搜索。因此,在每次循环运行时,它都会找到相同的元素。
.find()
res
如果要限制结果的数量,请使用切片表示法:
for elem in res.findAll('a')[:3]: print elem