简体   繁体   English

如何在 PyCharm 的活动选项卡中运行代码?

[英]How to run the code in the active tab in PyCharm?

I know it is not that cleaver question, however I am pretty new to PyCharm and Python.我知道这不是那个切肉刀的问题,但是我对 PyCharm 和 Python 还很陌生。

So as the question tells, I would like to make a shortcut to run the code in the active tab without going to the window "Edit Configurations" and change the running script manually.因此,正如问题所言,我想创建一个快捷方式来在活动选项卡中运行代码,而无需转到“编辑配置”窗口并手动更改正在运行的脚本。

I use OS 10.9.1, PyCharm edition 3.0.2我使用 OS 10.9.1,PyCharm 版本 3.0.2

You can simply right click and run:您只需右键单击并运行:

在此处输入图片说明

Go "Settings -> Project Interpreter -> Python Interpreter" and add your interpreter (the green '+' at up right corner of "settings" windows).转到“设置 -> 项目解释器 -> Python 解释器”并添加你的解释器(“设置”窗口右上角的绿色“+”)。

Then, already will available the green Play button (together the 'bug' icon) to run your project from Pycharm.然后,已经可以使用绿色的“播放”按钮(以及“错误”图标)从 Pycharm 运行您的项目。

For MacOS (10.5 keymap):对于 MacOS(10.5 键盘映射):

Ctrl + Shift + R Ctrl + Shift + R

在此处输入图片说明

Not sure why the windows answer was accepted...不知道为什么 Windows 答案被接受...

Sorry for being so late but I was having the same problem.抱歉这么晚了,但我遇到了同样的问题。 Maybe will help others in the future.也许将来会帮助别人。

In PyCharm version 2021.2.1 go to:在 PyCharm 版本 2021.2.1 中,转到:

File --> Settings --> Keymap --> Run Context Configuration --> Right Click --> Add Keyboard Shortcut.文件-->设置-->键盘映射-->运行上下文配置--> 右键单击​​ --> 添加键盘快捷键。

The screenshot bellow will help you more.下面的截图会帮助你更多。

PyCharm 快照

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM