“inconsistent use of tabs and spaces in indentation”

后端 未结 28 2186
北恋
北恋 2020-11-22 00:56

I\'m trying to create an application in Python 3.2 and I use tabs all the time for indentation, but even the editor changes some of them into spaces and then print out \"inc

28条回答
  •  终归单人心
    2020-11-22 01:41

    Generally, people prefer indenting with space. It's more consistent across editors, resulting in fewer mismatches of this sort. However, you are allowed to indent with tab. It's your choice; however, you should be aware that the standard of 8 spaces per tab is a bit wide.

    Concerning your issue, most probably, your editor messed up. To convert tab to space is really editor-dependent.

    On Emacs, for example, you can call the method 'untabify'.

    On command line, you can use a sed line (adapt the number of spaces to whatever pleases you):

       sed -e 's;\t;       ;' < yourFile.py > yourNedFile.py
    

提交回复
热议问题