使用python的Visual Studio代码

奥赞基本版

我已经在Ubuntu中安装了Visual Studio Code。但是我不能使用Python。

一些信息:

我没有安装任何python版本。我目前在终端或Python闲置2.7上使用它

谁能帮我?

内芬

VS Code不像Node.js或C#那样开箱即用地支持Python。它提供语法高亮,缩进和非常基本的代码提示,仅此而已。特别是您必须在不调试的情况下工作。

另一方面,它非常灵活且易于扩展,因为它允许定义自定义“任务”。特别是,您可以定义一个Run Build任务,默认情况下,该任务是通过Ctrl+ Shift+执行的B(要查看所有可用命令的列表,请按Ctrl+ Shift+ P。)

  1. 打开一个Python文件,然后按Ctrl+ Shift+ B它将打开一条消息“未配置任务运行器”。这是在Windows上,但在Ubuntu上看起来完全一样。

    配置任务运行器

  2. 按“配置任务运行器”。它将打开/创建.vscode/tasks.json项目文件夹下的文件。

    注意:在版本中,0.8.0该文件夹名为.settings

    默认运行任务

  3. 将说明替换为

    {
        "version": "0.1.0",
        "command": "python",
        "args": ["${fileBasename}"],
        "showOutput": "always"
    }
    

    并保存文件。

    新运行任务

  4. Go back to your Python file and press Ctrl+Shift+B again. It should run the code with python and show the output in an output pane. Note however, that it will not work if you're reading from stdin somewhere, as Code only displays the output, but does not allow for input.

See also:

As said in the beginning, VSCode's strengths really are Node, TypeScript, C#, as it offers IntelliSense and debugging capabilities.

我个人非常喜欢JetBrains PyCharm社区版它占用了一些内存,但是却带来了诸如自动完成,调试,对虚拟环境的支持等所有优点。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章