Python 在 PyCharm 中重命名文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26454624/
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
Renaming a file in PyCharm
提问by Karnivaurus
In PyCharm 3.4, I want to rename a file on the file tree that appears on the left of the IDE. If I right-click on a file, there is an option to delete it, but not to rename it. Similarly, there is no way of renaming it from the File or Edit menus. Is there a fundamental reason why PyCharm does not allow this from within the IDE, or have I missed the correct way of doing it?
在 PyCharm 3.4 中,我想重命名出现在 IDE 左侧的文件树上的文件。如果我右键单击一个文件,可以选择删除它,但不能重命名它。同样,无法从“文件”或“编辑”菜单重命名它。PyCharm 不允许在 IDE 中执行此操作是否存在根本原因,或者我是否错过了正确的执行方法?
采纳答案by Ffisegydd
Renaming files in PyCharm is simple. You simply select Refactor > Renamewhen right-clicking on a file in the tree.
在 PyCharm 中重命名文件很简单。您只需Refactor > Rename在右键单击树中的文件时进行选择。
This will open a popup where you can type in the new filename. There are additional options when renaming, such as searching for references and in comments, strings, etc.
这将打开一个弹出窗口,您可以在其中键入新文件名。重命名时还有其他选项,例如搜索参考文献和注释、字符串等。
NOTE:While PyCharm is indexing files, the option is unavailable. Once indexing is finished (can take a while), it becomes available again (thanks @Eric_Sven_Puudist).
注意:当 PyCharm 正在索引文件时,该选项不可用。一旦索引完成(可能需要一段时间),它就会再次可用(感谢@Eric_Sven_Puudist)。
回答by Padraic Cunningham
You can just choose the file and hit shift+F6rename it then hit refactor
您可以选择文件并点击shift+F6重命名,然后点击重构

