python - 在 HTML 页面中嵌入作为 HTML 的 Python 输出
问题描述
有没有办法可以将此代码嵌入到 HTML 文件中,而不是让它成为文本?如果这是一个糟糕的解释,我很抱歉,但代码和图片应该更好地结合我的想法。
Python:
table = [best_words[0:5]]
p = (tabulate(table, tablefmt='html'))
end = time.time()
final_time = '{:.2f}'.format((end-start))
return render_template('index.html', prediction=('{}'.format(p)), final_time=final_time)
Python的输出:
<table>
<tbody>
<tr><td>the</td><td>a</td><td>,</td><td>-</td><td>that</td></tr>
</tbody>
</table>
HTML 文件:
<h5>Genrated text:</h5>
</div>
<table> <tbody>{{ prediction }} </tbody> </table></div></div> </header>
解决方案
使用代码标签
<code>
-- Something here
</code>
推荐阅读
- javascript - Kendo UI - 将参数传递给 read().data() 中的 JS 函数
- python - 获取http状态码python selenium
- java - Java Jigsaw JUnit 测试 - JUnit 不在模块中
- ios - Swift 崩溃报告`函数签名专业化`
- pandas - DataFrame.apply(func, raw=True) 好像没有生效?
- php - php如何在不创建根目录的情况下提取zip并保留子目录?
- c++ - 具有非模板类型参数的模板函数的重载决议
- jenkins - 詹金斯构建不是模拟器
- c++ - Rust 找不到 Microsoft C++ 构建工具
- amazon-web-services - 将标头从查看器请求传递到 AWS lambda@Edge 中的源请求