leetcode449.py
def serialize(self, root):
        """Encodes a tree to a single string.

        :type root: TreeNode
        :rtype: str
        """
        strings = []
        def pre_search(node):
            if not node:
                return
            strings.append(node.val)
            pre_search(node.left)
            pre_search(node.right)

        pre_search(root)
        return '#'.join(str(s) for s in strings)
Encodes a tree to a single string.

        :type root: TreeNode
        :rtype: str
        
Encodes a tree to a single string.
Encodes a tree to a single string .
def serialize(self, root):
        strings = []
        def pre_search(node):
            if not node:
                return
            strings.append(node.val)
            pre_search(node.left)
            pre_search(node.right)
        pre_search(root)
        return '#'.join(str(s) for s in strings)
def serialize ( self , root ) : strings = [ ] def pre_search ( node ) : if not node : return strings . append ( node . val ) pre_search ( node . left ) pre_search ( node . right ) pre_search ( root ) return '#' . join ( str ( s ) for s in strings )
Encodes a tree to a single string.
Encodes a tree to a single string .
"""Encodes a tree to a single string.

        :type root: TreeNode
        :rtype: str
        """
None
str
self
root