VS Code позволяет отправлять код Python от редактора до того, что он называет «Native REPL» (интерфейс типа Jupyter без полных возможностей блокнота) или «Terminal REPL» (старое доброе приглашение Python >>>). См. https://code.visualstudio.com/docs/python/run.
Я предпочитаю работать в REPL терминала. У меня настроены сочетания клавиш на использование Ctrl+Enter (вместо Shift+Enter) для отправки выделенного фрагмента на терминал:
Код: Выделить всё
[
{
"key": "ctrl+enter",
"command": "python.execSelectionInTerminal",
"when": "editorTextFocus && !findInputFocussed && !isCompositeNotebook && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "shift+enter",
"command": "-python.execSelectionInTerminal",
"when": "editorTextFocus && !findInputFocussed && !isCompositeNotebook && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
}
]
Редактор:
Код: Выделить всё
print("Hello, World!")
Код: Выделить всё
>>> print("Hello, world!")
Hello, world!
Код: Выделить всё
>>>
KeyboardInterrupt
>>> print("Hello, world!")
Hello, world!
Код: Выделить всё
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
Код: Выделить всё
print("Hello, world!")Код: Выделить всё
>>> print("Hello, world!")
Traceback (most recent call last):
File "", line 0, in
KeyboardInterrupt
Как я могу исправить функцию отправки на терминал?
Подробнее здесь: https://stackoverflow.com/questions/791 ... on-windows
Мобильная версия