How To Debug a Pyhon Program

本文介绍了如何在Python IDLE环境中运行和调试Python程序。详细解释了通过菜单或快捷键启动程序的方法,以及如何利用打印语句进行简单的调试。更重要的是,文章深入探讨了如何在IDLE中设置断点,使用调试器控制程序执行流程,为读者提供了高效的Python调试技巧。

I have used python for several months and find it important to know how to debug a python program, to toggle breakpoints, to view the stacks and so on.

How to run a program in IDLE

In python IDLE, we can click menu Run -- Run Module to execute our program, alse we can use F5.

Perhaps the most common way to debug program is to PRINT! We can print types, values even where the program is.

But just printing out is not a good method, it's inconvenience and inefficient.

So we need to toggle break points and control the program as we need.

How to debug a program with IDLE

In python IDLE, we can click menu Run -- Python Shell, and in Python Shell, we can choose Debug -- Debugger. Thus there will be a window for Debug Control. Then you will need to go back to the window of Edit Window and Press F5. In this way, you start your debugger. Also you can toggle breakpoints in the Edit Window.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值