我试图在html主体中添加一个变量,但它不起作用。
import boto3
SENDER = "xyz@abc.com"
RECIPIENT = "abc@abc.com"
AWS_REGION = "yyy"
SUBJECT = "Title"
BODY_HTML =
"""
<!doctype html>
....
#somecode
<td>{email}</td>
</html>
BODY_HTML.replace("{", "{{").replace("}", "}}").format(email="ffdks@ncsdk")变量在电子邮件中以{ email }形式发送,而不是以ffdks@ncsdk的形式发送。
当替换不在那里时,如:
BODY_HTML.format(email="ffdks@ncsdk")它抛出一个错误
BODY_HTML.format(email="email") KeyError:'\n字体系列‘
发布于 2021-04-01 17:05:32
尝试添加:
BODY_HTML = """<!doctype html>
....
#somecode
<td>{email}</td>
</html>
"""
BODY_HTML = BODY_HTML.format(email="lakjsdfl"))
BODY_HTML.replace("{", "{{").replace("}", "}}")https://stackoverflow.com/questions/66901402
复制相似问题