📜  python递归保存值 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:31.197000             🧑  作者: Mango

代码示例1
def to_string(node):
    def actual_recursive(node):
        nonlocal a_str        # ~global, can modify surrounding function's scope.
        a_str += str(node.val)
        if node.next != None:
            actual_recursive(node.next)
    a_str = ''
    actual_recursive(node)
    return a_str