Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在HTML页面中嵌入HTML格式的Python输出_Python_Html - Fatal编程技术网

在HTML页面中嵌入HTML格式的Python输出

在HTML页面中嵌入HTML格式的Python输出,python,html,Python,Html,有没有一种方法可以将此代码嵌入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=('{}'.

有没有一种方法可以将此代码嵌入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>
Genrated文本:
{{预测}}
使用代码标签

<code>
-- Something here
</code>

{{预测|安全}

应该这样做,我认为

如果您标记了您正在使用的框架,这会有所帮助。
<table> <tbody>{{ prediction|safe }} </tbody> </table></div></div> </header>