None
如果在退出函数调用时未指定return ,Python将始终返回。您的选择是:
选项1(不满足条件时返回其他内容):
def html_check(td, text):
if td.text == text:
value = td.find_next('td').text
return value
return "no value found"
选项2(如果None
返回则忽略该函数):
if html_check(td, 'section'):
# do things