我是python的新手.我发现我的python代码返回不合理地返回选项卡错误:
msgs ['to'] ="xxx@gmail.com"
^ TabError:缩进中标签和空格的使用不一致
这是我的代码的一部分:
def send_email(self):
try:
msgs = MIMEMultipart()
msgs['to'] = "xxx"
msgs['from'] = "xxx"
msgs['subject'] = "abc"
msgs.attach(MIMEText(file("~/att1.py").read())
msgs.attach(MIMEText(file("~/att2.docx").read())
server = smtplib.SMTP()
server.connect('smtp.gmail.com:587')
server.login('xxx','xxx')
server.sendmail(msgs['from'], msgs['to'],msgs.as_string())
server.quit()
print "Successfully sent email"
return True
except SMTPException:
print "Error: unable to send email"
print str(SMTPException)
return False
Run Code Online (Sandbox Code Playgroud)