Kyle
Kyle

Reputation: 183

How to run code in Pycharm "Python Console"?

If I open the Pycharm IDE, go to "tools" and select "Python Console", and copy and paste

a=1
b=1
c=1

into the console, how do I execute this? If my cursor is at the end of the script (i.e., placed after c=1), I can just hit enter and it works. But the script will not execute if the cursor is placed on one of the first two lines. Hitting Enter only adds a new line between a=1 and b=1. Shift+Enter doesn't work either. Does anyone know how to execute the code without worrying if the cursor is at the very end of the script?

Upvotes: 1

Views: 7841

Answers (2)

andy kan
andy kan

Reputation: 212

To run source code from the editor in console:

  1. Open file in the editor, and select a fragment of code to be executed.

  1. On the context menu of the selection, choose Execute selection in console, or press Ctrl+Alt+E:

origin link

Upvotes: 4

Shane Kao
Shane Kao

Reputation: 185

Alt + Shift + E to execute current line in console

Upvotes: 1

Related Questions