问题
I am very new to Python and I am used to R studio so I choose Spyder. On the Spyder layout I saw a button 'run current line (ctrl +f10)'. But it doesn't work by pressing the button or c+10. Am I missing something? I can only select the script and 'ctrl+enter ' to run current line which is not convenient at all. I am using ubuntu with Anaconda distribution.
回答1:
The key to run the current line by itself is F9
. The shortcut ctrl+F10
is used if you are in debugging mode.
You can see a list of shortcuts by selecting Preferences
in the Tool
menu, and then clicking on Keyboard shortcuts
.
回答2:
Coming from R studio I imagine you were hoping to have a command that runs the next command, rather than just that one row (which can break a command into several parts and cause errors).
The exact equivalent doesn't exist yet but if you get accustomed to adding #%% before and after chunks ("cells") you want to run together then you can use the following commands to run the whole chunk.
Run cell: Ctrl + Return
Run cell and advance : Shift+Return
回答3:
Some keyboards have a different layout than others in terms of what the keys are supposed to do. For me running happens if done via Fn + F9
.
回答4:
F9
is the key that does the job for you.
To replicate the RStudio style, go to Preferences
in Tools
menu and go to Keyboard Shortcuts
.
Since Ctrl + Enter
is assigned to another function, change that first.
Then assign the F9
key value to Ctrl + Enter
. Now Spyder is the same as RStudio. Atleast in a way.
回答5:
Control Enter is a quick way of executing a line or block of code in both R Studio & Python.
In Spyder, make sure the line or block is highlighted before you hit 'ctrl-enter'
来源:https://stackoverflow.com/questions/39031796/how-to-run-current-line-in-spyder-3-5-ctrl-f10-not-working