相关疑难解决方法(0)

Sublime Text 2 - 查看空白字符

Sublime Text如何显示不可打印的字符(我对SPACE和TAB感兴趣)?

sublimetext sublimetext2

426
推荐指数
6
解决办法
22万
查看次数

如何修复Python缩进

我有一些Python代码具有不一致的缩进.有很多标签和空格的混合使事情变得更糟,甚至空间压痕也不会被保留.

代码按预期工作,但很难维护.

如何在不破坏代码的情况下修复缩进(如HTML Tidy,但对于Python)?

python

253
推荐指数
9
解决办法
24万
查看次数

我得到一个IndentationError.我如何解决它?

我有一个Python脚本:

if True:
    if False:
        print('foo')
   print('bar')
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行我的脚本时,Python提出了一个IndentationError:

  File "script.py", line 4
    print('bar')
               ^
IndentationError: unindent does not match any outer indentation level
Run Code Online (Sandbox Code Playgroud)

我一直在玩我的程序,我还能够产生其他三个错误:

  • IndentationError: unexpected indent
  • IndentationError: expected an indented block
  • TabError: inconsistent use of tabs and spaces in indentation

这些错误意味着什么?我究竟做错了什么?我该如何修复我的代码?

python error-handling code-formatting exception indentation

38
推荐指数
1
解决办法
2万
查看次数