[英]I would like to manipulate the data from the views to / render (html) in Django
[英]I would like to insert a html from result of pandas into an entire html
我希望有人能够帮助我形成以下我面临的问题。
我只想将 pandas 结果中的 html 插入到整个 html 中,如下所示,
...
df_add_html=df_add.to_html()
template="""<html>
<head></head>
<body>
Pandas : left-only<br>
I want to insert df_add_html here
</body>
</html>"""
part1=MIMEText(template. 'html')
msg.attach(part1)
...
目的是我想将 pandas 中的许多结果合并到 html 并且我将发送 email 和 ZFC369FDC70D82ZCA.
我希望我能得到你的一些建议。
谢谢。
您可以使用标准format()
template = "text {} text".format(df_add_html)
或f-string
template = f"text {df_add_html} text"
template = """<html>
<head></head>
<body>
Pandas : left-only<br>
{}
</body>
</html>""".format(df_add_html)
或者
template = f"""<html>
<head></head>
<body>
Pandas : left-only<br>
{df_add_html}
</body>
</html>"""
顺便说一句: http://pyformat.info
如果您需要更复杂的模板(即使用for
-loop 或if/else
),那么您可以使用用于在Flask
中生成 HTML 的jinja (但您可以生成任何文本文件)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.