码迷,mamicode.com
首页 > 其他好文 > 详细

A sample printer of nested lists

时间:2015-03-04 20:57:53      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

def print_list(the_list,indent=False,level=0):
    for each_line in the_list:
        if isinstance(each_line,list):
            print_list(each_line,indent,level+1)
        else:
            if indent:
                for tab_stop in range(level):
                    print(‘\t‘,end=‘‘)
            print(each_line)

A sample printer of nested lists

标签:

原文地址:http://www.cnblogs.com/yunmenglingxiao/p/4314208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!