Как убрать или выровнять по левому краю пустое пространство от данных, очищенных с помощью BeautifulSoup?
Данные преобразуются в str из Unicode.
пробовал str.strip () и str.ljust (), str.replace ("\ n", ""). Проверка каждого символа на None и отображение, если нет None, также не работает
from bs4 import BeautifulSoup
import requests
with open('f.html') as f:
soup=BeautifulSoup(f,'lxml')
article = soup.findAll('div',class_='modal-content')
for i in article:
print (str(i.text).strip())
Получено:
reset to default listTour
Start here for a quick overview of the site
Help Center
Detailed answers to any questions you might have
ожидаемый результат:
reset to default listTour
Start here for a quick overview of the site
Help Center
Detailed answers to any questions you might have