求二叉树深度的三种方法:递归、层次遍历、深度遍历 递归: class Solution: def TreeDepth(self, p): # write code here # 终止条件: if not p: return 0 return max(self.TreeDepth(p.left), self.TreeDepth(p.right)) + 1 层次遍历: