TabError: inconsistent use of tabs and spaces in indentation
これで困っちゃってます。
ソースはこれ
#メール送信関数
def send_mail():#送受信先to_email = "test@hoge.com"from_email = "test@hogehoge.com"#MIMETextを作成message = "Some probrem happend client ID:[hoge010]"msg = MIMEText(message,"html")msg["Subject"] = "Error"msg["To"] = to_emailmsg["From"] = from_emailsmtp_obj.login("test@hoge.com","PASSWD")smtp_obj.set_debuglevel(True)smtp_obj.send_message(msg)# python 2.7 環境ではこちらを使う。#閉じるsmtp_obj.quit()
これを python3 で実行すると
msg["To"] = to_email^TabError: inconsistent use of tabs and spaces in indentation
要するに、タブとスペースを混同しているから統一しなさいよというエラー。
うーん、、、困ったというところでこのブログを終わろうとしたところでひらめいた。
インデントに Tab を使ってるけどこれがいかんのでは?
良く考えたら、文法的にインデントが結構重要な言語ですよね。
続報はまた後日。
追記 2020-03-28
解決しました!
python3 ではインデントにTabを使っているのがまずいっぽいです。
すべてをスペースでインデントに直したらエラーが消えました。
python2系ではTabでも動いたんですけどね。
という訳で同じ事象でお困りの方は是非!