如何在 html 的帮助下打印 python 中的变量?
How to print variable present in python with the help of html?
我已经为深度学习文本摘要编写了一些代码,我正在尝试使用 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>
下面是输出图像
enter image description here
谁能帮我如何在网页上显示预测变量中的文本?
你需要双花括号
<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>
下面是输出图像
enter image description here
谁能帮我如何在网页上显示预测变量中的文本?
你需要双花括号
<p><strong>{{ prediction }}</strong></p>