Python 如何将表格中的数据添加到电子邮件内容?

Python 如何将表格中的数据添加到电子邮件内容?,python,django,Python,Django,如何将表格中的数据(姓名、电话和内容)添加到电子邮件内容 或 你可以用 body = "Your data: name: " + name + ", phone: " + str(phone) + ", your question: " + content 它适用于新旧python版本最具python风格的方法是使用string.format() 像这样: 您还可以在string.format()中传递dict body = "Your data: name: %s, phone: %s,

如何将表格中的数据(姓名、电话和内容)添加到电子邮件内容

你可以用

body = "Your data: name: " + name + ", phone: " + str(phone) + ", your question: " + content

它适用于新旧python版本

最具python风格的方法是使用
string.format()

像这样:

您还可以在
string.format()
中传递
dict

body = "Your data: name: %s, phone: %s, your question: %s" % (name, phone, content)
body = "Your data: name: " + name + ", phone: " + str(phone) + ", your question: " + content
"Your String".format()
first_name = 'Peter'
last_name = 'Pan'
email = 'peter.pan@wunderland.com'

body = 'Hello, my name is {first_name} {last_name}. Send me a mail to {email}.'.format(first_name=first_name, last_name=last_name, email=email)