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