如何在 spyder 中自动完成括号

How to autocomplete brackets in spyder

python 和 spyder 的新手。 有没有办法在 spyder 中自动完成括号?!

还有办法实现自动缩进吗? 我冒着让它过于宽泛的风险,但是还有一种方法可以确保如果说我正在定义一个函数,我可以简单地单击函数的末尾而不突出显示所有内容以使其成为 运行。 示例:

def print_twice(Spam):
 print(Spam)
 print(Spam)

在上面我想 运行 最后一行但是有 spyder 运行 def print_twice(Spam) to print(Spam) 的所有内容 如果这个问题很烦人或已经有了答案,谢谢和抱歉。找不到它。

(这里是 Spyder 维护者) 我的回答:

Is there a way to autocomplete brackets in spyder?

括号默认自动完成。

Also is there a way to get auto indentation?

自动缩进也会自动工作,在 : 之后或通过在左括号上对齐代码。

is there also a way to make sure that if say I'm defining a function, I can simply click at the end of the function without highlighting everything to make it run[?]

不,但是您可以为 运行 您的函数创建一个单元格。单元格是代码中由 # %% 形式的注释分隔的区域,您可以 运行 使用 Ctrl+Enter (运行 单元格并留在其上)或 Shift+Enter (运行 单元格并前进到下一个单元格)。