How can I run my currently edited file in a PyCharm console in a way that I can type into the command line afterwards?

前端 未结 3 953
不知归路
不知归路 2020-12-13 14:38

I want this so I can retain the command line history after repeated runs, and to paste lines from the console into tests etc. Exactly like in IDLE.

[I realize this q

相关标签:
3条回答
  • 2020-12-13 15:03

    Shift+Alt+Ewould execute the selected code.

    0 讨论(0)
  • 2020-12-13 15:03

    For anyone still having this problem: Go to the Run/Debug menu, choose Edit Configuration, check the box 'Show command line' this will enable you to enter parameters in the console at the >>> prompt and test your function.

    Edit: To make this change apply to all your .py files (as this check box only applies to the current file you're working on) go to: Edit configuration, in the pop up you will see a menu tree on the left, select Defaults, then Python, then check the 'Show command line' box, this will make it the default setting whenever you open a .py file, (this feature should really be on by default!)

    0 讨论(0)
  • 2020-12-13 15:22

    Select the code fragment or the entire file, then use Execute Selection in Console from the context menu.

    0 讨论(0)
提交回复
热议问题