Henry
发布于 2025-02-25 / 9 阅读
0
0

Visual Studio Code - 配置 Python 开发环境

背景简介

使用 visual studio code 开发 Python 时,我们可能需要根据不同的项目指定不同的 Python 开发环境,本文将如何设置 Python 版本进行记录。

环境配置

  1. Python 3.12.9

详细步骤

第一步: 在 Visual Studio Code 中使用快捷键 Ctrl+Shift+P

第二步: 输入 Python: Select Interpreter,如无对应选项,请先安装 Python 拓展。【Visual Studio Code - 安装拓展应用

第三步: 点击后选择 Python 环境所在的路径

第四步: 选择完成后,我们编辑一个 hello_world.py python 文件并执行测试

  • 编写 Python 脚本
def say_hello():
    print("Hello, World!")

if __name__ == "__main__":
    say_hello()
  • 打开 Terminal

  • 在底部 Terminal 中输入 python hello_world.py  执行脚本即可。
$ python hello_world.py 
Hello, World!

以上便是本文的全部内容,感谢您的阅读,如遇到任何问题,欢迎在评论区留言讨论。



评论