我有一个非结构化列表作为输入,需要在运行多项分析之前对其进行展平。一旦我获得每个输入的结果,将它们放回到原始列表的相同结构中的最佳方法是什么?
inputList = [["a", ["b","c","d"], [["e"]], "f"],["g"]]
flattenedList = myFlattenListFunction(inputList)
# a number of calculations based on the inputList
# ...
flattenedResults = [0, 1, 2, 3, 4, 5, 6, 7]
#What is the best solution to restructure the results to match the inputLists?
[[1, [2,3,4], [[5]], 6], [7]]
["e"]
)展平。 - donkopotamuschain.from_iterable([anything])
只会给你anything
。 - Adam Smith