Now suppose there is a list of robotic accessories list[Head, torso, limb]
This list has a nose, eyes, mouth, these little parts.
This list of limbs has arms, shoulders, and hands. Hand, this list has 3 different fingers.
So this list is written in detail:
LIST=[[1,2,3,4],5,[6,7,[8,9,10]] #我们type (list) It's totally list.
We need to explain this list, after all, it is not in line with the aesthetic, and for programming unfamiliar people will not look ah.
Do we have to write a lot for the For loop print this ist?
For Each_item in list if Isinstance (each_item,list): For Eacha_item in Each_item:if isinstance (eacha_item,list): For Eachaa_item in Eacha_item:if isinstance (eachaa_item,list): for Eachaaa_item in Eachaa_ite M:print (Eachaaa_item) else:print (Eachaa_item) else:print (Eacha_item) E Lse:print (Each_item)
#当你打完这些你一定会mmp的, easy to hit the wrong to say, a lot of repeating code!
def print_99 (list): For Each_item in List:if isinstance (each_item,list): print_99 (Each_item) else:print (Each_item)
Things are so happy to solve, this programming idea, feeling a lot, seems to have some understanding of object-oriented programming. I think of myself for one hours, it seems that this is the way, very way
Python tips 01 Recursive interpretation inline