小编Eva*_*Lee的帖子

python3不合理地返回TabError:缩进中使用制表符和空格不一致

我是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)

python smtp indentation

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

indentation ×1

python ×1

smtp ×1