在像 IDLE 这样的 Python shell 中在 VSCode 中运行 Python [英] Run Python in VSCode in python shell like IDLE

查看:37
本文介绍了在像 IDLE 这样的 Python shell 中在 VSCode 中运行 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很清楚线程如何从 Visual Studio Code 中执行 Python 代码

但是他们都没有展示如何在导入文件的情况下运行 >>> python shell.因为我想单独调用函数.我知道我可以通过在终端中简单地输入 python 来启动 python shell,但每次都必须手动导入 python 文件中的函数.

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.

有没有办法像在 IDLE 中一样在 VSCode 中运行文件?

Is there a way to run files in VSCode like in IDLE?

推荐答案

您可以使用参数 -i 在 VSC 代码终端中以交互模式运行文件:python -i py_file.py

you can run the file in an interactive mode in VSC code terminal by using the parameter -i : python -i py_file.py

这篇关于在像 IDLE 这样的 Python shell 中在 VSCode 中运行 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆