Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use PDB to realize Python Program debugging

Shulou Source: shulou.com Published: 2022-06-03 14:53:44 11月15日 Update

This article introduces the relevant knowledge of "how to use PDB to achieve Python program debugging". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

How to debug Python programs?

1. Add breakpoint

Add the red code where you need to insert the breakpoint: if the _ debug value is True, start debugging there (the reason for adding _ DEBUG is to turn debugging on / off).

#! / usr/bin/python _ DEBUG=True def debug_demo (val): if _ DEBUG= = True: import PDB PDB.set_trace () if val

Tags: Program instruction breakpoint code run content variable command more knowledge line number input utility achievement next up and down context usage function reason Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info Xiaomi OPPO Reno NVidia