我已经创建了一个python脚本来使用gmail帐户发送电子邮件。我使用的是Python3.7,但当我运行该程序时,它在消息框中显示为"EOL while scanning string literal"。有人能解决这个问题吗?如果你能找到解决的办法就告诉我。
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
#Next, log in to the server
server.login("youremailusername", "password")
#Send the mail
msg = "
Hello!" # The /n separates the message from the headers
server.sendmail("you@gmail.com", "target@example.com", msg)发布于 2018-12-29 20:26:52
EOL =行尾
此错误告诉您在扫描字符串文字时遇到“行尾”。正常字符串不应为多行。
使用三重引号来解决这个问题:
msg = """
Hello!"""发布于 2018-12-29 20:30:04
你有一个打字错误
msg = ""只有当存在未结束的字符串时,才会弹出错误。
https://stackoverflow.com/questions/53969415
复制相似问题