spyder debug



按钮作用:

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值