I am trying to store the html result inside a variable but it displays none.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lively Forest</title>
<!-- Recommended meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- PyScript CSS -->
<link rel="stylesheet" href="https://pyscript.net/releases/2023.12.1/core.css">
<!-- This script tag bootstraps PyScript -->
<script type="module" src="https://pyscript.net/releases/2023.12.1/core.js"></script>
</head>
<body>
<script type="py">
from pyscript import display,HTML
x = display(HTML("<h1>hello</h1>"))
display(x)
</script>
</body>
</html>
how can i store it inside a variable?
x = display(HTML("<h1>hello</h1>"))
display(x)
You're saving the result of display()
, but you actually want the result of HTML()
.
Use this instead:
x = HTML("<h1>hello</h1>")
display(x)