当前位置:   article > 正文

Mac上的VS code在终端直接运行.py_mac vscode 运行指定python行

mac vscode 运行指定python行

假设在Vscode 界面写了一个test.py.

print("Hell")
def su(x,y):
    return x*y
  • 1
  • 2
  • 3

step1. 将test.py拖到终端,这样自动产生了文件路径。注意只需要
cd '/****/algorithms'
即可。因为拖过去之后显示的
cd '/****/algotithms/test.py.
要把后面的test.py 删掉。只需要保留test.py 的上层文件即可。

step2. 这时候若只是想运行test.py . 只需要在终端输入 python3 test.py 就会出现 Hell. 如果想要调用su 这个函数的话,见step3

step3. 在终端输入python3 进入python编译器,会出现>>> 这时候输入

>>> from test import su
Hell
>>> su(3,4)
12
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/734259
推荐阅读
相关标签
  

闽ICP备14008679号