Create a multi-tiered list (that is, a list of stored lists) and output list items
The following figure:
You can see that the output is only output out of the list
Of course, you can iterate through each subkey multiple times: As shown in the following figure
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
Note: Isinstance (object, ClassInfo) is a built-in function of Python to determine the type of object
This is a three-tier loop, and it's too cumbersome to recycle the For loop output for many times.
For this situation, a function needs to be established, and the recursive loop output child
As shown in the following illustration:
Simply create a function print_lol (), and if the built-in function isinstance () determines that the subkey is a list, call the function print_lol () itself
The movies is then used as the parameter of the function print_lol to invoke the function output list subkey
For this nested list, you can also output one of the items by using an array subscript
Such as:
>>> print (movies[5][1][1])
sex
>>>
Author: csdn Blog Friends of the Yangtze River