Python-full resolution of nested list and python-full resolution
A layer-3 nested list m
M = ["a", ["B", "c", ["inner"]
Basic data items a, B, c, and inner must be parsed.
Basic data extraction methods:
For I in m:
Print I this can only retrieve the first layer of a, and a second layer of nested list ["B", "c", ["inner"]
Combined with built-in functions and judgment, you can continue to parse this list of 2 layers.
For I in m: if isinstance (I, list): for j in I: print jelse: print I result abc ['inner ']
This layer-2 Nesting is also separated, but the list in it is not split. Although the splitting can continue to obtain the result, it is not the best choice.
Constructor, iteratively parse this multi-layer nested list
Def printm (listin): for I in listin: if isinstance (I, list): printm (I) else: print I use this function to directly parse the nested list, remove printm (m) at a time)
The result is as follows:
Abcinner
The full analysis of the above Python-nested list is all the content shared by the editor. I hope you can give us a reference and support the house of helpers.