python學習(一)開發環境部署,python開發環境部署

來源:互聯網
上載者:User

python學習(一)開發環境部署,python開發環境部署

簡要說明:

1.設定環境變數

2.vscode python環境設定

3.hello world

 

一、設定環境變數

  不管是在windows平台還是linux平台,首先的一步就是下載python安裝包,然後設定python環境。

  環境變數:path:d:\python\Python36\;d:\python\Python36\Scripts\

  測試是否設定成功:開啟命令提示字元視窗,輸入:python

  

二、vscode python開發環境設定

  開發工具採用vscode,檔案->喜好設定->使用者佈建 開啟settings.json 設定檔,在右側修改配置;若不想修改全域的配置,可將 在【使用者佈建】下拉選項中選擇【工作區設定】,這樣就只會影響到當前程式

  

 

三、 hello world

  可以進行開發啦。。。

  a. 互動式編程

    聽著感覺很高大上,在命令提示字元視窗輸入print("hello world"),然後斷行符號等著出結果,這就是互動式編程,exit() 退出python

    

  b. 指令碼編程(命令列模式)

    又是什麼鬼,建立一個檔案 py_helloworld.py , 輸入 print("hello world") , 儲存,在命令列中輸入 python py_helloworld.py。。。這就是指令碼編程

    

  c.  vscode 開發工具使用

    開啟vscode,安裝python擴充

    

    開啟py_helloworld.py 所在檔案夾,需要使用到tasks.json(運行環境配置)、launch.json(調試環境配置)。(使用預設的tasks.json、launch.json 也可以運行,可不建立,直接F5運行即可)

    tasks.json : 任務->配置任務->使用模板建立tasks.json檔案->other,Command修改為python

 1 { 2     // See https://go.microsoft.com/fwlink/?LinkId=733558 3     // for the documentation about the tasks.json format 4     "version": "2.0.0", 5     "tasks": [ 6         { 7             "taskName": "echo", 8             "type": "shell", 9             "command": "python"10         }11     ]12 }

    launch.json : 調試->開啟配置->python ,可以不修改。(stopOnEntry : 在程式第一行停止,可配置調試時程式第一行為斷點)

    F5 運行

    

    

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.