标签:else lol item pytho lse int evel span 嵌套
names = [‘A‘,‘B‘,‘C‘,[‘D‘,‘E‘],[‘F‘]] def print_lol(the_list,indent=False,level=0): # for each_item in the_list: if isinstance(each_item,list): print_lol(each_item,indent,level+1) else: if indent: for tab_top in range(level): print("\t",end=‘‘) print(each_item)
print_lol(names,True,4) #首行缩进4格输出
A B C D E F
print_lol(names,True)
A
B
C
D
E
F
print_lol(names)
A B C D E F
标签:else lol item pytho lse int evel span 嵌套
原文地址:https://www.cnblogs.com/kevin-hou1991/p/13621325.html