Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way i can store html output inside a variable?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading