在线debug 与 断点

日常使用

  1. 在线debug
rlaunch --gpu=2  --cpu=8 --memory=20480 --charged-group=v_traffic  -L 5678 -- zsh
python3 -m ptvsd --wait --host 0.0.0.0 --port 5678
  1. 设置断点
  • iPython
from IPython import embed
embed()
  • ipdb
import ipdb
ipdb.set_trace()

help:显示帮助信息
a: 查看变量的值
n: 单步运行
dir(): 查看一个对象有哪些方法可以调用

配置

# 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: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            //端口号要与程序运行时保持一致
            "port": 1504,
            "host": "10.124.153.136",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "enter-your-module-name-here",
            "console": "integratedTerminal"
        },
        {
            "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": {
                "   LASK_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-11-11 13:25  小康要好好学习  阅读(56)  评论(0编辑  收藏  举报