我正在尝试向 thml 内容添加一个字符串,但我得到的字符串不符合要求
应将“str1”添加到“附件是您的数据报告 - +str1”中来代替 str1
str1= 'StringToBeAdded'
html_content1 = ''' Hi All,
<br>
<br>
Greetings from xyz!
<br>
Attached is the report of your data - + str1
<br>
<br>
Note: This is an automated email. In case of any queries, please reach us at
<br>
Regards,
<br>
abc '''
message = Mail(
from_email='[email protected]',
[email protected]',
subject='Mail,
html_content=html_content1)
预期产出
附件是您的数据报告 - StringToBeAdded
提前致谢
您需要正确引用,请参见下文,以便将 str1 视为变量,您的帖子将其显示在 ''' 内,这样它就不会被解释为仅作为文本的变量。
str1= 'StringToBeAdded'
html_content1 = ''' Hi All,
<br>
<br>
Greetings from xyz!
<br>
Attached is the report of your data - ''' + str1 + '''
<br>
<br>
Note: This is an automated email. In case of any queries, please reach us at
<br>
Regards,
<br>
abc '''