本文介绍了如何使用 IDLE (Python gui) 取消缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 IDLE (Python GUI) 中编写以下语句

>>> 如果 x == 0:... x = 0... print('负数变为零')... elif x == 0:

如何获得 elif 语句的缩进?

一些额外的事实:

  1. 我试过退格键和 shift + tab 键,没用.
  2. 在 Windows 上运行.

谢谢.

抱歉,您应该只使用退格键,因为 ">>>" 并不打算缩进.这意味着在:

>>> 如果 x == 54:x = 4elif y = 4:y = 6

elif 和 if 语句一样缩进.

很抱歉浪费您的时间...,尽管您可以责怪 IDE 制作了一个不言自明的 UI.

解决方案

试试这样输入.你会注意到光标在 pass

之后移动到行首>>>如果 x == 0:x = 0print('负数变为零')经过elif x == 0:打印('其他东西')

I want to write the following statment in IDLE (Python GUI)

>>> if x == 0:
...      x = 0
...      print('Negative changed to zero')
... elif x == 0:

How can I get the unindention for the elif statment ?

Some additional facts:

  1. I tried backspace and shift + tab, that doesn't help.
  2. Runing on Windows.

Thanks.


Sorry, you should just use backspace, thing is that ">>>" does not intent on indentation.That means that in:

>>> if x == 54:
         x = 4
elif y = 4:
         y = 6

elif is just as indented as the if statment.

Sorry to waste your time..., although you can blame the IDE for making an un-selfexplanitory UI.

解决方案

Try typing it like this. You'll notice the cursor moves to the start of the line after the pass

>>> if x == 0:
        x = 0
        print('Negative changed to zero')
        pass
elif x == 0:
    print('other stuff')

这篇关于如何使用 IDLE (Python gui) 取消缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:05