Python电子邮件 - 使用冒号不会导致输出

Kil*_*izo 5 python email

真的奇怪的经历,花了我一个多小时才弄明白.我有一个用python编写的cgi脚本,它接受表单数据并将其转发到电子邮件,问题是,如果字符串中有冒号,则会导致python不向电子邮件输出任何内容.

有人知道为什么吗?

例如:

output = "Print- Customer"
Run Code Online (Sandbox Code Playgroud)

但有效:

output = "Print: Customer"
Run Code Online (Sandbox Code Playgroud)

打印没有输出.

我的电子邮件功能主要是:

server.sendmail(fromaddr, toaddrs, msg)
Run Code Online (Sandbox Code Playgroud)

其中msg =输出

只是想知道冒号是否是python字符串输出中的特殊字符

Rus*_*ove 6

冒号不是python字符串输出中的特殊字符,但它对于电子邮件标题是特殊的.尝试在输出中插入一个空行:

output = "\nPrint: Customer"
Run Code Online (Sandbox Code Playgroud)