pip install < package > вызвать ошибку & ldquo; Файлы / каталоги не найдены в & rdquo;

Попробуйте:

def stringify_children(node):
    from lxml.etree import tostring
    from itertools import chain
    parts = ([node.text] +
            list(chain(*([c.text, tostring(c), c.tail] for c in node.getchildren()))) +
            [node.tail])
    # filter removes possible Nones in texts and tails
    return ''.join(filter(None, parts))

Пример:

from lxml import etree
node = etree.fromstring("""<content>
Text outside tag <div>Text <em>inside</em> tag</div>
</content>""")
stringify_children(node)

Производит: '\nText outside tag <div>Text <em>inside</em> tag</div>\n'

0
задан Hans Deragon 15 January 2019 в 19:37
поделиться