In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what python debugging skills are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Debugging skills
1. Script debugging
Script debugging for Python can be done using the pdb module. It allows us to set breakpoints at will in the script:
Import pdb pdb.set_trace ()
You can specify pdb.set_trace () and set breakpoints anywhere in the script, which is very convenient
two。 Debug programs in shell
In shell, you can start an interactive environment by using the-I option of python, where you can print run-time variable values and call functions, such as the following test.py script
Def func (): return 0 / 0 func ()
Run the script through python-I test.py in shell
We import pdb and then call pdb.pm () to start the debugger
It will show the place where the program crashes, where we exit the program and set a breakpoint:
Import pdb; def func (): pdb.set_trace () return 0 / 0 func ()
Run it again, it will stop at the breakpoint, step to the next step
In this way, we can debug and trace the execution of the program. By setting a breakpoint, and then when you run the program, execution stops at the breakpoint, and you can check the program, such as listing function parameters, evaluating expressions, listing variables, or step stepping.
This is the end of this article on "what are the python debugging skills?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.