问题
I am well aware of the thread How to execute Python code from within Visual Studio Code
But none of them shows how to get the >>> python shell running with the file imported. Cuz I would like to call functions separately.
I understand that I can get the python shell going by simply typling python
in the terminal but the functions in the python file have to manually imported everytime.
Is there a way to run files in VSCode like in IDLE?
回答1:
you can run the file in an interactive mode in VSC code terminal by using the parameter -i : python -i py_file.py
回答2:
Assuming you have the official Python extension installed, you can search the command list (Ctrl+Shift+P) for "Python interactive" and you'll see several options that allow to do different variations of this:
来源:https://stackoverflow.com/questions/58557135/run-python-in-vscode-in-python-shell-like-idle