1. 程式人生 > 實用技巧 >第十一週

第十一週

首次瞭解Python

python有2 和 3 代,2代編碼並不預設UTF-8

python2需要在開頭引用# -*- coding: UTF-8 -*-或# coding=utf-8

python3 預設UTF-8

也可以# -*- coding: xxxx-*-轉為不同指定的編碼

python3環境配置很簡單,但是配置vscode需要下載外掛和配置編譯器

Ctrl+Shift+P搜尋

找到python安裝地址

然後需要配置setting.json和launch.json

setting.json

{
    "python.pythonPath": "E:\\python\\python.exe
" }

launch.json

{
     // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            
"type": "python", "request": "launch", "stopOnEntry": false, //"python": "C:/Python27/python", "python": "E:/Python/python.exe", "program": "${file}", "cwd": "${workspaceRoot}", "env": {}, "envFile": "${workspaceRoot}/.env
", "debugOptions": [ "WaitOnAbnormalExit", "WaitOnNormalExit", "RedirectOutput" ] }, { "name": "Python: Attach", "type": "python", "request": "attach", "port": 5678, "host": "localhost" }, { "name": "Python: Django", "type": "python", "request": "launch", "program": "${workspaceFolder}/manage.py", "console": "integratedTerminal", "args": [ "runserver", "--noreload", "--nothreading" ], "django": true }, { "name": "Python: Flask", "type": "python", "request": "launch", "module": "flask", "env": { "FLASK_APP": "app.py" }, "args": [ "run", "--no-debugger", "--no-reload" ], "jinja": true }, { "name": "Python: Current File (External Terminal)", "type": "python", "request": "launch", "program": "${file}", "console": "externalTerminal" } ] }