Generally, str
objects display on the console. How can I convert my html
object to an str
object so that it can display on the console?
x = HTML('<p>hello</p>')
string = str(x)
display(string)
Generally, str
objects display on the console. How can I convert my html
object to an str
object so that it can display on the console?
x = HTML('<p>hello</p>')
string = str(x)
display(string)
try using
html2text
script ; import html2text html_content = ‘<p>hello</p>’ text_content = html2text.html2text(html_content) print(text_content)@Sumanjha if you’re going to provide full code, please write an answer, not a comment.
What is
HTML
in this case? (which package are you importing?)I am importing from pyscript import HTML . @Suman jha your code works for me but displays few blank spaces after display.