Python通过递归遍历出集合中所有元素的方法
作者:erix1991 时间:2022-08-28 01:36:43
本文实例讲述了Python通过递归遍历出集合中所有元素的方法。分享给大家供大家参考。具体实现方法如下:
'''''通过递归遍历出集合中的所有元素
Created on 2013-9-29
@author: L.Eric
'''
def print_List(list_nums):
for each_item in list_nums :
if isinstance(each_item,list):
print_List(each_item)
else:
print(each_item)
movies = ["aaa","bbb","ccc","ddd",["qqq","sss",["mmm","rrr",["tt","ccs"]]]]
print_List(movies)
希望本文所述对大家的Python程序设计有所帮助。
标签:Python,递归,遍历
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
数字人组件反写[asp组件开发实例2]
2009-06-09 13:15:00
![](https://img.aspxhome.com/file/UploadPic/20093/9/200939182821210s.gif)
动态生成的IFRAME设置SRC时的,不同位置带来的影响
2008-03-06 13:56:00
python实战游戏之史上最难最虐的扫雷游戏没有之一
2021-03-08 04:43:03
![](https://img.aspxhome.com/file/2023/8/66748_0s.gif)
python小项目之五子棋游戏
2022-07-12 06:24:23
![](https://img.aspxhome.com/file/2023/8/72848_0s.jpg)
Python人工智能实战之对话机器人的实现
2021-03-20 15:59:18
![](https://img.aspxhome.com/file/2023/7/75977_0s.jpg)
Alexa排名数据xml接口及其参数说明
2008-11-07 13:03:00
解读Scrapy回调函数callback传递参数的方式
2022-12-02 04:12:53
Django框架中间件(Middleware)用法实例分析
2021-01-04 09:27:38
![](https://img.aspxhome.com/file/2023/4/85154_0s.png)
asp HTTP 500错误 常见问题分析
2011-04-07 10:33:00
python zip,lambda,map函数代码实例
2023-08-25 05:04:49
pandas带有重复索引操作方法
2023-04-19 20:22:12
隐藏并修改文件的最后修改时间的asp-webshell
2009-02-28 13:31:00
![](https://img.aspxhome.com/file/UploadPic/20092/28/crackfile-48s.gif)
asp三天学好ADO对象之第二天
2008-10-09 12:49:00
Python深度学习albumentations数据增强库
2023-02-14 20:00:18
![](https://img.aspxhome.com/file/2023/2/75372_0s.jpg)
Pycharm基本操作及调试代码
2022-08-13 08:38:55
![](https://img.aspxhome.com/file/2023/8/76038_0s.jpg)
Access:数据转换问题
2008-11-20 17:02:00
js页面跳转常用的几种方式
2023-08-07 08:30:27
Python 运行 shell 获取输出结果的实例
2023-08-02 16:51:18
详细讲解Access数据库远程连接的实用方法
2008-11-28 16:34:00
如何用python实现结构体数组
2023-10-13 19:07:34