推荐学习书目
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
smallpython
V2EX  ›  Python

如何调试一个正在运行的 Python 程序?

  •  
  •   smallpython · Oct 29, 2019 · 5797 views
    This topic created in 2414 days ago, the information mentioned may be changed or developed.
    我想看到变量的值
    16 replies    2019-11-30 10:33:23 +08:00
    wlsnx
        1
    wlsnx  
       Oct 29, 2019   ❤️ 1
    Sylv
        2
    Sylv  
       Oct 29, 2019 via iPhone
    问就是 PyCharm。
    wuwukai007
        3
    wuwukai007  
       Oct 29, 2019   ❤️ 1
    已经跑以来的程序,没试过,不过要是可以跑之前加个 pysnooper
    pip install pysnooper
    ligyxy
        4
    ligyxy  
       Oct 29, 2019   ❤️ 1
    今天的 PyCoder’s Weekly 提到了一个
    https://github.com/julvo/reloading
    ClericPy
        5
    ClericPy  
       Oct 29, 2019   ❤️ 1
    google 上随便一搜 python debug running 有好几个吧, 这东西以前在周报只看到过 gdb, 刚随手一搜也有不少啊
    simple2025
        6
    simple2025  
       Oct 29, 2019
    print?
    smallpython
        7
    smallpython  
    OP
       Oct 29, 2019
    @Sylv pycharm 还能调试正在运行的程序吗
    smallpython
        8
    smallpython  
    OP
       Oct 29, 2019
    @ClericPy 我知道,我这不是想看看 v 友有没有什么好用的方法嘛
    ggicci
        9
    ggicci  
       Oct 29, 2019
    @wlsnx 卡尔大哥能带飞吗
    Sylv
        10
    Sylv  
       Oct 29, 2019
    @smallpython 当然可以,断点调试啥的都可以。
    tiedan
        11
    tiedan  
       Oct 29, 2019
    推荐试试神器 pdb
    ruabiubiubiu
        12
    ruabiubiubiu  
       Oct 29, 2019
    @ggicci 你就不怕是钢筋卡么
    ggicci
        13
    ggicci  
       Oct 29, 2019
    @ruabiubiubiu 不怕,我是万年辅助,只躺不动
    scriptB0y
        14
    scriptB0y  
       Oct 31, 2019
    可以用 https://github.com/benfred/py-spy 照一下看看程序在干嘛;

    angwer 在去年分享过调试工具,其中有一部分是可以做到不重启程序的,可以看下: https://github.com/HZPUG/HZPUG.github.io/blob/master/lectures/2018-11-25/%E6%88%91%E7%9A%84Python%E8%BF%9B%E7%A8%8B%E6%80%8E%E4%B9%88%E4%BA%86.pdf
    lowman
        15
    lowman  
       Nov 30, 2019
    @smallpython 可以, 打断点, 手动执行下一步, 输出变量值, 本地调试, 远程调试都可以,
    lowman
        16
    lowman  
       Nov 30, 2019
    大型的 web 项目, 如果不是需要进行特别复杂的调试, 直接 print 大法就行了..........
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4792 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 09:51 · PVG 17:51 · LAX 02:51 · JFK 05:51
    ♥ Do have faith in what you're doing.