How to print variable present in python with the help of html?(如何借助html打印python中的变量?)

I’ve written some code for deep learning text summarization, and I’m trying to render the template using the Flask library. I’m unable to see the results. The python code can be found below.

    text = ' '.join([summ['summary_text'] for summ in res])
    print(text)
return render_template('result.html', prediction=text)

I’m trying to print the prediction variable which is present in the above code. Below is the html code

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>

    <header>
        <div class="container">
        <div id="brandname">
            Deep Learning App
        </div>
        <h2>Summarized text</h2>
        
    </div>
    </header>
    <p style="color:blue;font-size:20;text-align: center;"><b>Result for Text</b></p>
    <div class="results">


    
    <p><strong>{prediction}</strong></p>

    </div>

</body>
</html>

Below is output image

enter image description here

Can anyone help me how to display text present in prediction variable on web page?

Solution:

You need double curly braces

<p><strong>{{ prediction }}</strong></p>
————————

我已经为深度学习文本摘要编写了一些代码,我正在尝试使用Flask库呈现模板。我看不到结果。python代码可以在下面找到。

    text = ' '.join([summ['summary_text'] for summ in res])
    print(text)
return render_template('result.html', prediction=text)

我试图打印上面代码中的预测变量。下面是html代码

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>

    <header>
        <div class="container">
        <div id="brandname">
            Deep Learning App
        </div>
        <h2>Summarized text</h2>
        
    </div>
    </header>
    <p style="color:blue;font-size:20;text-align: center;"><b>Result for Text</b></p>
    <div class="results">


    
    <p><strong>{prediction}</strong></p>

    </div>

</body>
</html>

下面是输出图像

在此处输入图像描述

有人能帮我在网页上显示预测变量中的文本吗?

解决方法:

你需要双卷背带

<p><strong>{{ prediction }}</strong></p>