Python 如何在邮件脚本中将变量传递给html?
我的代码如下:Python 如何在邮件脚本中将变量传递给html?,python,Python,我的代码如下: success_msg='''\ <html> Hi. {{ name }} ... ''' def sendmail(sender,receiver,title,content,username): ... if __name__ == '__main__': sendmail(XXX,XXX,XXX,success_msg,usernameXX) success\u msg=''\ 你好{{name}} ... ''' def
success_msg='''\
<html>
Hi. {{ name }}
...
'''
def sendmail(sender,receiver,title,content,username):
...
if __name__ == '__main__':
sendmail(XXX,XXX,XXX,success_msg,usernameXX)
success\u msg=''\
你好{{name}}
...
'''
def sendmail(发件人、收件人、标题、内容、用户名):
...
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
sendmail(XXX,XXX,XXX,success\u msg,usernameXX)
如何在html中将“用户名”传递给“名称”?
如何用html编写代码?使用:
HTML示例:
>>> header = '<html><head><title>Sample</title></head><body>'
>>> body = '<p>Hello <strong>$name</strong></p>'
>>> footer = '</body></html>'
>>> html = Template(header+body+footer)
>>> html.substitute(name='World')
'<html><head><title>Sample</title></head><body><p>Hello <strong>World</strong></
p></body></html>'
>标题='Sample'
>>>body='你好$name'
>>>页脚=“”
>>>html=模板(页眉+正文+页脚)
>>>html.substitute(name='World')
“样本你好世界”
是的,只要是字符串就行了。
>>> header = '<html><head><title>Sample</title></head><body>'
>>> body = '<p>Hello <strong>$name</strong></p>'
>>> footer = '</body></html>'
>>> html = Template(header+body+footer)
>>> html.substitute(name='World')
'<html><head><title>Sample</title></head><body><p>Hello <strong>World</strong></
p></body></html>'