单步调试调试leetcode代码

单步调试调试leetcode代码

  LeetCode代码通过Playground获取调试代码,然后通过赋值代码到本地的Pycharm进行单步调试

概述

  LeetCode有三种Playground:控制台Playground:链表(Linked list),树(Binary tree);前端程序:React。LeetCode里面的Playground调试只能通过stdin输入实例,执行调试之后直接就获得输入结果。通过复制粘贴Playground代码到Pycharm可以进行单步调试。不同的控制台Playground调试过程类似,本文以104. 二叉树的最大深度中的树(Binary tree)的控制台Playground和Pycharm进行单步执行从而调试自己写的代码。

一、选择语言,输入调试代码

 

二、通过Playground获取调试代码

 1、代码提交平台跳转到Playground

2、复制粘贴Playground当中全部的代码

三、通过Pycharm调试代码

1、修改代码:ctr +R 将null全改成None

2、设置断点,单击连接调试。在控制台输入测试实例(enter),进行单步调试。stdin实例中需要将null全改成None

3、进行单步调试获取代码bug的位置并进行修改获得运行结果如下,具体运行过程在调试器中可以查看

4、'str' object has no attribute 'decode'

python3的不需要decode了,因为python3的str没有decode的这个属性了,直接删除!

def stringToString(input):
return input[1:-1].decode('string_escape')
修改为:
def stringToString(input):
return input[1:-1]
 

 

posted @ 2019-12-17 18:53  石斛  阅读(3705)  评论(0编辑  收藏  举报