Copy-paste into Python interactive interpreter and indentation

前端 未结 8 1674
借酒劲吻你
借酒劲吻你 2020-12-06 00:41

This piece of code, file test.py,

if 1:
   print \"foo\"
print \"bar\"

can be successfully executed with execfile(\"test.py\

8条回答
  •  伪装坚强ぢ
    2020-12-06 01:01

    If you are like me and use Notepad++ (to copy and paste from), try to replace tabs by spaces by going to menu SettingsPreferencesLanguage and check the replace by spaces.

    I had this problem myself for so long and I found out that python.exe recognizes spaces.

提交回复
热议问题