I'm wondering if there is a way to display HTML text that can update itself in Python with Jupyter Notebooks.
In other words, I want to be able to say:
<p>Hi there!</p>
and then....
<p>Go away!</p>
but instead of producing two lines of text, I want the first line to be changed into the second.
Any ways to achieve this? (I assume it requires some kind of JS, but I'm not sure how to do that)...
EDIT:
I originally asked how to update Python text like: print("Hello World")
but I specifically want to update HTML text because I want to be able to apply CSS properties to the text.
This worked for me:
from IPython.display import display
import ipywidgets as widgets
import time
out = widgets.HTML()
display(out)
out.value="<p>Hi there!</p>"
time.sleep(1)
out.value = "<p>Go away!</p>"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.