Результат возврата python отличается, и я не понимаю, почему:
from bs4 import BeautifulSoup
def recurse_table(table, table_list):
if table.find_next("table") is not None:
recurse_table(table.find_next("table"), table_list)
table_list.append(table)
return table_list
fp = open("tc4400_cs_2.html")
soup = BeautifulSoup(fp.read(), features="html.parser")
print(len(recurse_table(soup.find("table"), [])))
возвращает правильную длину (4).
Принимая во внимание
from bs4 import BeautifulSoup
def recurse_table(table, table_list):
if table.find_next("table") is not None:
recurse_table(table.find_next("table"), table_list)
return table_list.append(table)
fp = open("tc4400_cs_2.html")
soup = BeautifulSoup(fp.read(), features="html.parser")
print(len(recurse_table(soup.find("table"), [])))
возвращает TypeError: объект типа 'NoneType' не имеет len ()
Чего мне не хватает?