What to do with “Unexpected indent” in python?

前端 未结 17 2384
天涯浪人
天涯浪人 2020-11-22 07:46

How do I rectify the error \"unexpected indent\" in python?

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:06

    In Python, the spacing is very important, this gives the structure of your code blocks. This error happens when you mess up your code structure, for example like this :

    def test_function() :
       if 5 > 3 :
       print "hello"
    

    You may also have a mix of tabs and spaces in your file.

    I suggest you use a python syntax aware editor like PyScripter, or Netbeans

提交回复
热议问题