如何在 Python 中取消缩进代码块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32710832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I unindent blocks of code in Python?
提问by
I am using Python 2.7.10 and am having trouble trying to unindent a block of code. Surely there is some sort of shortcut, instead of having to backspace every individual line?
我正在使用 Python 2.7.10 并且在尝试取消缩进代码块时遇到问题。当然有某种快捷方式,而不是必须退格每一行?
From the Python Shell, I opened a new file (.py) and that's where I am writing the code.
在 Python Shell 中,我打开了一个新文件 (.py),这就是我编写代码的地方。
Shift + Tab does not work.
Shift + Tab 不起作用。
采纳答案by Psytho
It is Ctrl + [in IDLE. You can change it to your favorite Shift + Tabin Options -> Configure IDLE - Keys. You need to restart the shell after that.
在 IDLE 中是Ctrl + [。您可以在Options -> Configure IDLE - Keys中将其更改为您最喜欢的Shift + Tab。之后您需要重新启动shell。
回答by Shubham Sharma
You can unindent using following keys:
您可以使用以下键取消缩进:
In Python IDLE/Spyder: Ctrl + [
In Eclipse: Shift + Tab
In Visual Studio: Shift+ Tab
In PyCharm: Shift + Tab
In Jupyter Notebook: Shift + Tab