Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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
Python 我想把熊猫结果中的html插入到整个html中_Python_Html_Pandas_Email - Fatal编程技术网

Python 我想把熊猫结果中的html插入到整个html中

Python 我想把熊猫结果中的html插入到整个html中,python,html,pandas,email,Python,Html,Pandas,Email,我希望有人能帮助我形成以下我所面临的问题 我只想将pandas结果中的html插入整个html,如下所示 ... df_add_html=df_add.to_html() template="""<html> <head></head> <body> Pandas : left-only<br>

我希望有人能帮助我形成以下我所面临的问题

我只想将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)
...
其目的是,我想合并从熊猫到html的许多结果,我将发送一封带有html的电子邮件

我希望你能给我一些建议

谢谢。

您可以使用标准格式

或f字串

顺便说一句:


如果您需要更复杂的模板,例如for循环或If/else,那么您可以使用用于在Flask中生成HTML的模板,但您可以生成任何文本文件

text{}text.formatdf_add_HTML,并将df_add_HTML替换为{}。或者使用f-string-ftext{df_add_html}textBTW:非常感谢您的回答。我找到了我想要的结果,我也找到了根本原因。
template = "text {} text".format(df_add_html) 
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>"""