不再怀疑

导航

第二章《共享你的代码》

  1.注释

  2.缩进

  代码:

    

def print_lol(the_list,level=0):
for each_item in the_list:
if isinstance(each_item,list):
print_lol(each_item,level+1)
else:
if ind:
for tab_stop in range(level):
print("\t",end='')
print(each_item)

  3.增加缺省默认值:

  

def print_lol(the_list,ind=False,level=0):
for each_item in the_list:
if isinstance(each_item,list):
print_lol(each_item,ind,level+1)
else:
if ind:
for tab_stop in range(level):
print("\t",end='')
print(each_item)

posted on 2017-01-09 15:38  不再怀疑  阅读(109)  评论(0编辑  收藏  举报