简体   繁体   中英

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 (ie, 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?

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

Alt + Shift + E在控制台中执行当前行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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