欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VSCode下配置python調(diào)試運行環(huán)境的方法

 更新時間:2018年04月06日 12:19:47   作者:落花微雨  
這篇文章主要介紹了VSCode下配置python調(diào)試運行環(huán)境的方法,需要的朋友可以參考下

VSCode配置python調(diào)試環(huán)境

很久之前的一個東東,翻出來看看

  • VSCode配置python調(diào)試環(huán)境
    * 1.下載python解釋器
    * 2.在VSCode市場中安裝Python插件
    * 4.在用戶設(shè)置里加兩條
    * 5.接下來是正式的調(diào)試了
    • 1080 兩個數(shù)的平方和
      • Input
      • Output
      • Input示例
      • Output示例

1.下載python解釋器

python 3.6.3 for windows

安裝到系統(tǒng)某個路徑例如C:\Python36
最好添加到Path,也可以不加

2.在VSCode市場中安裝Python插件

python插件

3.同樣是打開一個文件夾,新建一個.py文件(這樣容易識別項目,vscode就需要新建一個文件夾)
4.同樣是launch.json文件和tasks.json文件

launch.josn

{
 // 使用 IntelliSense 了解相關(guān)屬性。 
 // 懸停以查看現(xiàn)有屬性的描述。
 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
 "version": "0.2.0",
 "configurations": [
  {
   "name": "Python",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,//是否在第一條語句時程序停止,下面的這個選項都一樣
   "pythonPath": "C:/Python34/python",//可執(zhí)行文件路徑
   "program": "${file}",
   "cwd": "${workspaceRoot}",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "PySpark",
   "type": "python",
   "request": "launch",
   "stopOnEntry": true,
   "osx": {
    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
   },
   "windows": {
    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
   },
   "linux": {
    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
   },
   "program": "${file}",
   "cwd": "${workspaceRoot}",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "Python Module",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "module": "module.name",
   "cwd": "${workspaceRoot}",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "Integrated Terminal/Console",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "program": "${file}",
   "cwd": "",
   "console": "integratedTerminal",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit"
   ]
  },
  {
   "name": "External Terminal/Console",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "program": "${file}",
   "cwd": "",
   "console": "externalTerminal",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit"
   ]
  },
  {
   "name": "Django",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "program": "${workspaceRoot}/manage.py",
   "cwd": "${workspaceRoot}",
   "args": [
    "runserver",
    "--noreload",
    "--nothreading"
   ],
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput",
    "DjangoDebugging"
   ]
  },
  {
   "name": "Flask",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
   "cwd": "${workspaceRoot}",
   "env": {
    "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
   },
   "args": [
    "run",
    "--no-debugger",
    "--no-reload"
   ],
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "Flask (old)",
   "type": "python",
   "request": "launch",
   "stopOnEntry": false,
   "pythonPath": "${config:python.pythonPath}",
   "program": "${workspaceRoot}/run.py",
   "cwd": "${workspaceRoot}",
   "args": [],
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "Pyramid",
   "type": "python",
   "request": "launch",
   "stopOnEntry": true,
   "pythonPath": "${config:python.pythonPath}",
   "cwd": "${workspaceRoot}",
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "args": [
    "${workspaceRoot}/development.ini"
   ],
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput",
    "Pyramid"
   ]
  },
  {
   "name": "Watson",
   "type": "python",
   "request": "launch",
   "stopOnEntry": true,
   "pythonPath": "${config:python.pythonPath}",
   "program": "${workspaceRoot}/console.py",
   "cwd": "${workspaceRoot}",
   "args": [
    "dev",
    "runserver",
    "--noreload=True"
   ],
   "env": {},
   "envFile": "${workspaceRoot}/.env",
   "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
   ]
  },
  {
   "name": "Attach (Remote Debug)",
   "type": "python",
   "request": "attach",
   "localRoot": "${workspaceRoot}",
   "remoteRoot": "${workspaceRoot}",
   "port": 3000,
   "secret": "my_secret",
   "host": "localhost"
  }
 ]
}

tasks.json

 {
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
   {
    "taskName": "echo",
    "type": "shell",
    "command": "C:\\Python34\\python",//Python可執(zhí)行文件路徑
    "args": ["${file}"]
   }
  ]
 }

4.在用戶設(shè)置里加兩條

settings.json

 "python.pythonPath": "C:\\Python34\\python" ,//路徑
 "python.linting.enabled": false,//忘了是什么東西了,反正有用

Linting (Prospector, Pylint, pycodestyle, Flake8, pylama, pydocstyle, mypy with config files and plugin

靜態(tài)代碼掃描(可以理解為代碼語法和格式錯誤提示,支持多種linter)

5.接下來是正式的調(diào)試了

默認是Python選項
按\(<F5>\)啟動調(diào)試
然后在

中有一些東西就是這樣
但是這個默認的\(python\)選項并不能由用戶輸入
所以有

這個和下面的那個都可以
這個Intergrated……的選項是下圖的東東


其實這個可以直接


直接當成cmd來用同樣可以由用戶輸入
然后那個External……的選項只不過是開了一個控制臺窗口

2333……
剩下的可以自己試試
說不定有驚喜

翻出很久之前做的一道題目
用py3寫的
剛剛一直在用的test.py就是用的這道題的代碼

1080 兩個數(shù)的平方和

基準時間限制:1 秒 空間限制:131072 KB 分值: 5
給出一個整數(shù)N,將N表示為2個整數(shù)i j的平方和(i <= j),如果有多種表示,按照i的遞增序輸出。
例如:

(注:3 11同11 3算1種)

Input

一個數(shù)N()

Output

共K行:每行2個數(shù),i j,表示
如果無法分解為2個數(shù)的平方和,則輸出

Input示例

130

Output示例

3 11
7 9

相關(guān)文章

  • python3 實現(xiàn)mysql數(shù)據(jù)庫連接池的示例代碼

    python3 實現(xiàn)mysql數(shù)據(jù)庫連接池的示例代碼

    這篇文章主要介紹了python3 實現(xiàn)mysql數(shù)據(jù)庫連接池的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Python+Matplotlib繪制小提琴圖的示例代碼

    Python+Matplotlib繪制小提琴圖的示例代碼

    小提琴圖 (Violin Plot) 類似紡錘,是一種用來顯示數(shù)據(jù)分布和概率密度的圖形,本文為大家介紹了Matplotlib繪制小提琴圖的函數(shù)源碼,需要的可以參考一下
    2023-06-06
  • python之dlib包安裝失敗問題及解決

    python之dlib包安裝失敗問題及解決

    這篇文章主要介紹了python之dlib包安裝失敗問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • Python之tkinter文字區(qū)域Text使用及說明

    Python之tkinter文字區(qū)域Text使用及說明

    這篇文章主要介紹了Python之tkinter文字區(qū)域Text使用及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • 利用PyQt5+Matplotlib 繪制靜態(tài)/動態(tài)圖的實現(xiàn)代碼

    利用PyQt5+Matplotlib 繪制靜態(tài)/動態(tài)圖的實現(xiàn)代碼

    這篇文章主要介紹了利用PyQt5+Matplotlib 繪制靜態(tài)/動態(tài)圖的實現(xiàn)代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Python Flask前后端Ajax交互的方法示例

    Python Flask前后端Ajax交互的方法示例

    這篇文章主要介紹了Python Flask前后端Ajax交互的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • python 爬蟲爬取京東ps4售賣情況

    python 爬蟲爬取京東ps4售賣情況

    這篇文章主要介紹了python 如何用爬蟲爬取京東ps4售賣情況,幫助大家更好的利用python爬取自己想要的數(shù)據(jù),感興趣的朋友可以了解下
    2020-12-12
  • 在Pandas?DataFrame中插入一列的方法實例

    在Pandas?DataFrame中插入一列的方法實例

    在敲代碼的過程中,老是會遇到在Dataframe中新添加一列的情況,所以下面這篇文章主要給大家介紹了關(guān)于如何在Pandas?DataFrame中插入一列的方法實的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • python離線安裝外部依賴包的實現(xiàn)

    python離線安裝外部依賴包的實現(xiàn)

    今天小編就為大家分享一篇python離線安裝外部依賴包的實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02
  • python多線程同步之文件讀寫控制

    python多線程同步之文件讀寫控制

    這篇文章主要為大家詳細介紹了python多線程同步之文件讀寫控制,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-08-08

最新評論