我正在使用Python3.7和BeautifulSoup4。当我使用findAll时,如何找到匹配元素的数量?我有这个
# Verify that we didn't see a no results message
no_images_msg = "No very similar images were found on Reddit."
elts = soup.body.findAll(text=re.compile("^.*" + no_images_msg + ".*$"))
if elts.count != 0:
print("nothing found" + str(elts.count))
print(str(elts))
return json.dumps(results)
但是“elts.count!”0“子句的计算结果始终为true,即使通过print语句,我可以看到tehre没有元素
这很简单:
相关问题 更多 >
编程相关推荐