按钮作用:
1.debug file 进入调试
2.run current line 运行当前行
3.step into function or method of current line 进入函数或方法内运行
4.run until current function or method returns 跳出函数或方法
5.continue execution until next breakpoint 运行到下一个断点
6.stop debugging 退出调试
使用举例:
1.运行代码
2.在运行报错的那行代码设置断点
3.remove all variables
4.点击debug file
5.点击step into function or method of current line,直到结束
def piecewise(x, data):
data_len=len(data)
if(data[0][0]<=x<data[-1][0]):
for i in range(data_len-1):
if(data[i][0]<=x<data[i+1][0]):
fx=data[i][1]
break
elif x==data[-1][0]:
fx=data[-2][1]
else:
fx=None
return fx
if __name__ == '__main__':
# 测试数据
data=[(0, -1), (1, 0), (1.5, 4),(2, None)]
x=[0,1,1.5,2,3]
expected_output=[-1,0,4,4,None]
for i in range(0,len(x)):
actual_output=piecewise(x[i], data)
assert actual_output==expected_output[i],print('The actual_output is :', \
actual_output, 'but the expected_output is :', expected_output[i])
参考:
如何在Spyder中高效地Debug? - 知乎 (zhihu.com)
spyder调试教程(debug)_the Blog of 等不到天亮丶等时光-CSDN博客_spyder怎么debug