--- title: Visual Studio Code 撰寫 Python 程式 description: 本文章適用於 Windows 環境,使用 Visual Studio Code 撰寫 Python 程式。 langs: zh --- 本文章適用於 Windows 環境,使用 Visual Studio Code 撰寫 Python 程式。 --- [TOC] --- ## 一、安裝 Vscode: 1. 到 Vscode 官網下載 Vscode 的安裝檔。 連結:https://code.visualstudio.com/ ![Vscode_1](https://i.imgur.com/aXPuGbg.png) 2. 開啟安裝檔,接著只要一直按下一步就能安裝完成,到附加工作這一頁推薦全勾取。 ![Vscode_2](https://i.imgur.com/Yeb8YiG.png) 3. 安裝寫 Python 必備和更便利的擴充功能,先進入到管理擴充功能的地方,點擊最左邊工具列四個框框的圖標或者按下快捷鍵 Ctrl + Shift + X。 ![Vscode_3](https://i.imgur.com/85VNt2w.png) 4. 於輸入框中輸入想要安裝的功能名稱,接著按下安裝並重啟 Vscode 即可安裝完畢。 ![Vscode_4](https://i.imgur.com/Vl8vRuy.png) * **Chinese (Traditional) Language Pack for Visual Studio Code** 能將 Vscode 翻譯成繁體中文,對於英文不好的朋友簡直是一大福音。 連結:https://marketplace.visualstudio.com/items?itemName=MS-CEINTL.vscode-language-pack-zh-hant ![Vscode_5](https://i.imgur.com/oMKle7C.png) * **Python** 要寫 Python 程式語言,這是一定要裝的擴充功能。 連結:https://marketplace.visualstudio.com/items?itemName=ms-python.python ![Vscode_6](https://i.imgur.com/ITGpsaZ.png) ## 二、安裝 Python: 1. 到 Python 官網下載 Python 安裝檔,安裝最新版本即可。 連結:https://www.python.org/ ![Python_1](https://i.imgur.com/rDS09fL.png) 2. 開啟安裝檔,勾選 Add python.exe to PATH,讓 Python 自動加入 Windows 環境變數。 ![Python_2](https://i.imgur.com/LXLIf6S.png) 3. 將電腦重新啟動,讓環境變數生效。 ![Python_3](https://i.imgur.com/24kDXP4.png) ## 三、執行 Vscode 的第一個 Python: 1. 使用 Vscode 開啟一個資料夾,新增一個新檔案。 ![Vscode_7](https://i.imgur.com/Niz1L7W.png) 2. 寫出 Vscode 中的第一個 Python 程式 "Hello, world!" 吧。 ```python= print("Hello, world!") ``` 3. 如果終端機成功顯示 "Hello, world!" 的話,恭喜接下來就能開心寫 Python 程式囉! ![Vscode_8](https://i.imgur.com/tAwOjQ3.png) --- :::info 📢 歡迎加入我的 Discord 伺服器:https://discord.gg/Jtd3eVrFJs ::: :::info 📢 歡迎加入我的 FB 社團: https://www.facebook.com/groups/shawn20060304/ ::: *Copyright © 2022 SmallShawn95. All rights reserved.*