官术网_书友最值得收藏!

Code debugging

Code debugging is a process that can help you to understand the cause of an error, by providing an input to the code and walking through each line of the code and seeing how it evaluates at the end. The Python language contains some debugging tools to get insights from the code, starting with a simple print function, assert command till a complete unit testing for the code. PyCharm provides an easy way to debug the code and see the evaluated values.

To debug code in PyCharm (say, a nested for loop with if clauses), you need to set a breakpoint on the line at which you want PyCharm to stop the program execution. When PyCharm hits this line, it will pause the program and dump the memory to see the contents of each variable:

Notice that the value of each variable is printed besides it, on the first iteration:

Also, you can right-click on the breakpoint and add a specific condition for any variable. If the variable is evaluated to a specific value, then a log message will be printed:

主站蜘蛛池模板: 佛坪县| 哈尔滨市| 洛南县| 五峰| 民权县| 霍山县| 陈巴尔虎旗| 黎川县| 莱西市| 泸溪县| 无棣县| 老河口市| 龙山县| 响水县| 新蔡县| 枝江市| 惠东县| 凤凰县| 阳江市| 仁寿县| 高雄县| 湛江市| 天峨县| 方城县| 鲁甸县| 武鸣县| 广宁县| 米易县| 长兴县| 恭城| 乃东县| 义马市| 东至县| 大安市| 灵宝市| 申扎县| 永嘉县| 繁峙县| 平昌县| 勃利县| 宝应县|