Try   HackMD

(進階/選修/課外)在 VScode 裡更有效率執行 python 程式的方法

每次都要在終端機輸入 python xxx.py 很麻煩對吧?
其實 VScode 已經幫你內建好點擊按鈕 -> 執行 python 指令的機制

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

更進階

每次都還要用滑鼠?有沒有更懶人的方法?
安裝套件: Code Runner 之後,只要按 Ctrl + Alt + N
就會自動幫你執行了

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Debug: 使用 Mac 系統要把預設執行的 python 改成 python3

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 點『命令選擇區』(或快速鍵 Command + Shift + P)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 輸入 settings.js -> 選擇『喜好設定:開啟設定』

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 放入以下設定檔 (注意要放在大括號裡面,建議倒數第二行)
  "code-runner.executorMap": { // 套件 Code Runner 的設定
    // 執行 python 檔案時要用 python3 (-u => unbuffered)
    "python": "python3 -u",
  },
  1. 記得儲存 -> 測試看看吧!

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →