首页 > 编程语言 > 详细

Python list1

时间:2015-09-15 16:12:23      阅读:283      评论:0      收藏:0      [点我收藏+]
>>> movies =[
    "the holy grail", 1975,"terry jones",91,
    ["graham chapman",
     ["michel palin","john cheelse","terry gilliam","eric idle","terry jones"]]]
>>> print (movies)
[the holy grail, 1975, terry jones, 91, [graham chapman, [michel palin, john cheelse, terry gilliam, eric idle, terry jones]]]


>>> for each_item in movies:
    if isinstance(each_item,list):
        for nested_item in each_item:
            if isinstance(nested_item,list):    
                for last_item in nested_item:
                    print(last_item)
            else:
                print(nested_item)
    else:
        print(each_item)

        
the holy grail
1975
terry jones
91
graham chapman
michel palin
john cheelse
terry gilliam
eric idle
terry jones

 

Python list1

原文:http://www.cnblogs.com/oskb/p/4810492.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!