Python 在 Spyder 中更改变量名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23295576/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:40:59  来源:igfitidea点击:

Changing variable name in Spyder

pythonvariableseditorspyder

提问by VitOne

I have a program with many formulas and variables. I need to change the name of some of these variables. Is there any command or function in Spyderthat can help me change all the names in one step?

我有一个包含许多公式和变量的程序。我需要更改其中一些变量的名称。Spyder中是否有任何命令或函数可以帮助我一步更改所有名称?

I am looking for something like the Matlab's MAIUSC+ENTER.

我正在寻找类似于 Matlab 的 MAIUSC+ENTER 的东西。

回答by Mudit Jain

No way to do it currently. It's an open issue. https://github.com/spyder-ide/spyder/issues/415

目前没有办法做到。这是一个开放的问题。 https://github.com/spyder-ide/spyder/issues/415

回答by Ludo Schmidt

1) Select the variable you want to change, then Press CTRL + R
2) Enter the new variable name you want. (in replace by)
3) Replace all

enter image description here

在此处输入图片说明

回答by MI Alam

Alternatively, PyCharm can be used instead of Spyder, which is now supported in Anaconda.

或者,可以使用 PyCharm 代替 Spyder,后者现在在 Anaconda 中受支持。

In PyCharm: Select the variable >Right Click >Refactor >Rename

在 PyCharm 中:选择变量>右键单击>重构>重命名