如何debug
1.设置断点:在Python编辑器中要调试的代码行右击->Set Breakpoint,之后该行底色就变黄了
2.打开debugger:Python Shell->Debug->Debugger
3.在代码编辑窗口按F5或者是在run菜单中选择run model
4.debug过程略
· Go表示运行完,不过按F5后先要Go一下才能往下走,默认是不运行的
· Step表示一步一步
· Over表示跳过函数方法
Out表示跳出本函数
1、先用IDLE中写入完整源码
#*-coding:utf-8 -*-
'''''
figure the surface of cube
'''
class cube:
def __init__(self,l=2,w=3,h=4):
self. l=l
self.w=w
self. h=h
def surface(self):
result=( self.l* self.w+ self.l* self.h+ self.w* self.h)*2
print 'the surface of cube is' + str(result)
return result
def main():
L=raw_input('Plz input the length of the cube:')
L=int(L)
W=raw_input('Plz enter the width of the cube:')
W=int(W)
H=raw_input('Plz type in the height of the cube:')
H=int(H)
pCube=cube(L,W,H)
pCube.surface()
2、编辑保存之后,点击Run->Python Shell,就打开了Python Shell 窗口,在这个窗口菜单上,选择Debug->Debuger,这时就打开了Debug Control窗口
3、在IDLE那个源码窗口中点击Run->Run Module或按F5键,这时,就可以在Debug Control窗口里就看到了正要调试运行的程序的__main__模块被选中.
4、点击debug control中的Step按钮,就可以看到代码一步一步的执行过程,解释器是从上往下一个模块一个模块的扫描,它先找到名字为'__main__'中的模块,然后在main主函数中,查找其下面调用的函数处去依次执行