zoukankan      html  css  js  c++  java
  • 递归调用输出元素 分类: python 小练习 python基础学习 2013-06-30 11:54 278人阅读 评论(0) 收藏

    #使用递归,输出所有的列表元素

    l1 = [1,2,3,[4,5,6],[4,3,2,1,['a','b','c'],[ ] ] ]


    def getElement(l):
        for i in l:
            if isinstance(i,list):
                getElement(i)
            else:
                print i,

    getElement(l1) #结果:1 2 3 4 5 6 4 3 2 1 a b c

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    虚拟机网络配置常见问题总结
    Python
    Python
    Python
    Python
    Python
    Python
    MySQL
    MySQL
    MySQL
  • 原文地址:https://www.cnblogs.com/think1988/p/4628141.html
Copyright © 2011-2022 走看看