Найти - Пользователи
Полная версия: Можно ли как-нибудь поставить класс в html через Python?
Начало » Центр помощи » Можно ли как-нибудь поставить класс в html через Python?
1
Ridon
Можно ли как-нибудь поставить класс в html через Python?
FishHook
html = "<a class='%s'>link</a>" % "active"
py.user.next
>>> import lxml.html
>>> 
>>> node = lxml.html.fromstring('<a></a>')
>>> node.attrib['class'] = 'x'
>>> text = lxml.html.tostring(node)
>>> text
b'<a class="x"></a>'
>>>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB