class Solution: def threeOrders(self , root): # write code here self.results=[[],[],[]] self.preorder(root) self.inorder(root) self.postorder(root) return self.results # 前序遍历 def preorder(self,root): if root is None: return self.results[0].append(root.val) self.preorder(root.left) self.preorder(root.right) # 中序遍历 def inorder(self,root): if root is None: return self.inorder(root.left) self.results[1].append(root.val) self.inorder(root.right) # 后序遍历 def postorder(self,root): if root is None: return self.postorder(root.left) self.postorder(root.right) self.results[2].append(root.val)