开发者

What if beautifulsoups call returns null?

开发者 https://www.devze.com 2023-02-10 02:44 出处:网络
pagelinks = myhtml.findAll(\'a\') for link in pagelinks: do_stuff() 开发者_StackOverflow If pagelinks is null, will this error out?
pagelinks = myhtml.findAll('a')

for link in pagelinks:
   do_stuff()
开发者_StackOverflow

If pagelinks is null, will this error out?

How can I make pagelinks a collection of 0 items in case it is null?


findAll returns an empty list [] when nothing matches

for link in pagelinks:
    do_stuff()  # never executed when findAll returns []
0

精彩评论

暂无评论...
验证码 换一张
取 消