我的计划不能正常工作。我试图用html呈现图形,但它总是显示文本而不是图形本身。在
下面是用'应用程序副本'文件-使用烧瓶微框架。在
k = plotly.offline.plot({
"data": [go.Scatter(x = money_x, y = result, name = "Expenditure")],
"layout": go.Layout(title="Expenditure")
}, auto_open=True, show_link=False, output_type = 'div', include_plotlyjs=False)
return render_template('plot.html', name=session['name'], surname=session['surname'], k=str(k), sun=session['student_number'])
下面是html文件的摘录。在html中,我包含了一个在线图形,以便尝试看看代码有什么问题——但这之后返回了无意义的结果。在
^{pr2}$下面是观察到的程序输出的图片。正如人们所看到的,从网上得到的绘本图像没有受到伤害,而我生成的图形没有被翻译成情节丰富的内容。在
请帮忙
您需要告诉模板语言不要通过标记为安全来转义HTML:
请注意,您不必对plotly对象调用
str()
;模板将为您处理这些问题。在相关问题 更多 >
编程相关推荐