递归比较简单
class Solution(object):
def invertTree(self, root):
if root==None:
return
node = root
if node.left or node.right:
temp=node.left
node.left=node.right
node.right=temp
self.invertTree(node.left)
self.invertTree(node.right)
return root