简体   繁体   中英

Python code tabs not recognised between windows and linux

I am using a windows computer to write some python code and I upload it to my raspberry.

I use notepad++ on my computer and adobe brackets. In Adobe brackets, when I do 1 tab, it aligns it so the indentation is correct for python (for example, I hit tab only once and it is aligning as if it was 4 tabs). In notepad++ I can see 4 tabs.

But when I upload it to my raspberry which is linux and I use nano to see the file, I only see 1 tab instead of 4. That gives me of course a lot of errors.

Thanks if you can help,

John.

Hard tabs are interpreted as different characters on windows and linux. You should always use spaces for Python. You can use reindent.py to fix it on Windows and then it should work on both. This script should be located in your Python install directory. Usage is:

reindent.py badcode.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM