第十一周

首次了解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"
        }
    ]
}

 

posted @ 2021-01-10 20:40  韦德·沃兹  阅读(79)  评论(0)    收藏  举报