Python - 使用 GMAIL smtp 发送带附件的电子邮件出错

Python - Sending email with attachment using GMAIL smtp gives error

我正在尝试使用 Python 和 Google 的 smtp 发送电子邮件。调用后出现错误:

   msg = MIMEMultipart('alternative')
TypeError: 'LazyImporter' object is not callable

有没有人遇到同样的问题?解决方案是什么?

我的代码:

Pastebin code

只需将导入更改为

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase