V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
saximi
V2EX  ›  Python

请问 Visual Studio CODE 开发 Python 时如何设置断点

  •  
  •   saximi · 2017-07-13 20:16:11 +08:00 · 3082 次点击
    这是一个创建于 2480 天前的主题,其中的信息可能已经有所发展或是发生改变。
    安装了 python 插件,在想断点的行序号左侧点击鼠标后出现了红色圆点,本以为断点设置成功了,但是一按 F5 键,整个程序依然执行完毕,并没有在红点行停止运行,请问应该如何正确设置断点呢,谢谢
    7 条回复    2017-07-18 21:48:41 +08:00
    ivechan
        1
    ivechan  
       2017-07-13 20:25:59 +08:00
    这个就是正确方式。
    janxin
        2
    janxin  
       2017-07-13 20:30:24 +08:00


    同样的步骤没有任何问题
    nutting
        3
    nutting  
       2017-07-13 20:38:43 +08:00 via Android
    你确定逻辑走断点了?
    Miy4mori
        4
    Miy4mori  
       2017-07-13 21:03:19 +08:00 via iPhone
    楼上说的在理
    athomas
        5
    athomas  
       2017-07-13 22:34:57 +08:00
    是不是 vscode debug configuration 设置有问题?
    zhusimaji
        6
    zhusimaji  
       2017-07-13 23:38:17 +08:00 via iPhone
    三楼说的有道理,如果你设置的断点没有被执行到也是一晃而过,还是需要检查一下逻辑,最笨的方法就是在第一条语句打上断点,这样肯定会停下,让后 f10 单步调试
    saximi
        7
    saximi  
    OP
       2017-07-18 21:48:41 +08:00
    @athomas 应该是设置有问题,但是我不知道怎么设置才能使断点生效。我的 launch.json 中的相关内容如下:

    "version": "0.2.0",
    "configurations": [
    {
    "name": "Python",
    "type": "python",
    "request": "launch",
    "stopOnEntry": true,
    "pythonPath": "${config:python.pythonPath}",
    "program": "${file}",
    "cwd": "${workspaceRoot}",
    "env": {},
    "envFile": "${workspaceRoot}/.env",
    "debugOptions": [
    "WaitOnAbnormalExit",
    "WaitOnNormalExit",
    "RedirectOutput"
    ]
    },

    另外,F11 键既是单步调试模式,又是 VSCODE 全屏快捷键,我一按 F11 就切换全屏而无法进入单步执行,请问这又应该怎么做呢?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4827 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 112ms · UTC 03:59 · PVG 11:59 · LAX 20:59 · JFK 23:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.