Pycharm: run only part of my Python file

后端 未结 5 922
逝去的感伤
逝去的感伤 2020-12-02 06:07

Is it possible to run only a part of a program in PyCharm?

In other editors there is something like a cell which I can run, but I can\'t find such an option in PyCha

相关标签:
5条回答
  • 2020-12-02 06:49
    1. Go to File >> Settings >> Plugins and install the plugin PyCharm cell mode
    2. Go to File >> Settings >> Appearance & Behavior >> Keymap and assign your keyboard shortcuts for Run Cell and Run Cell and go to next

    A cell is delimited by ##

    Ref https://plugins.jetbrains.com/plugin/7858-pycharm-cell-mode

    0 讨论(0)
  • 2020-12-02 06:54

    You can set a breakpoint, and then just open the debug console. So, the first thing you need to turn on your debug console:

    enter image description here

    After you've enabled, set a break-point to where you want it to:

    enter image description here

    After you're done setting the break-point:

    enter image description here

    Once that has been completed:

    enter image description here

    0 讨论(0)
  • 2020-12-02 06:56

    Pycharm shortcut for running "Selection" in the console is ALT + SHIFT + e

    For this to work properly, you'll have to run everything this way.

    0 讨论(0)
  • 2020-12-02 06:59

    You can select a code snippet and use right click menu to choose the action "Execute Selection in console".

    0 讨论(0)
  • 2020-12-02 07:09

    I found out an easier way.

    • go to File -> Settings -> Keymap
    • Search for Execute Selection in Console and reassign it to a new shortcut, like Crl + Enter.

    This is the same shortcut to the same action in Spyder and R-Studio.

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