range()二元元组遍历
来源:互联网 发布:淘宝化妆品小样靠谱点 编辑:程序博客网 时间:2024/05/16 08:24
#使用range()循环遍历
tuple=(("apple","banana"),("grape","orange"),("watermelon",),("grapefruit",))
for i in range(len(tuple)):
print "tuple[%d]:" %i,"",
for j in range(len(tuple[i])):
print tuple[i][j],"",
print
#使用map()循环遍历
k=0
for a in map(None,tuple):
print"tuple[%d]:"%k,"",
for x in a:
print x,"",
print
tuple=(("apple","banana"),("grape","orange"),("watermelon",),("grapefruit",))
for i in range(len(tuple)):
print "tuple[%d]:" %i,"",
for j in range(len(tuple[i])):
print tuple[i][j],"",
#使用map()循环遍历
k=0
for a in map(None,tuple):
print"tuple[%d]:"%k,"",
for x in a:
print x,"",
k+=1
====================== RESTART: C:/Python27/range().py ======================
tuple[0]: apple banana
tuple[1]: grape orange
tuple[2]: watermelon
tuple[3]: grapefruit
tuple[0]: apple banana
tuple[1]: grape orange
tuple[2]: watermelon
tuple[3]: grapefruit
阅读全文
0 0
- range()二元元组遍历
- python中的一些遍历列表,元组,字符串等的方法,如:range,enumerate
- 遍历元组
- python6:序列之元组和range
- 广度遍历二元树
- 从上往下遍历二元树(层次遍历二元树)
- 按层次遍历二元树
- 按层次遍历二元树
- python基础-列表、元组、range、列表字符串转换
- golang range 遍历
- golang range 遍历
- python元组Tuple的遍历
- Python 元组遍历排序操作方法
- 元组、列表、字典、字符串的遍历
- 16.从上往下遍历二元树
- 二元树遍历与常见操作
- 从上往下遍历二元树
- 从上往下遍历二元树
- css 动态导航栏
- 解决deepin开机进入grub rescue> ,无法启动, 修复开机引导
- 必然
- 母函数
- Connection refused: connect 异常问题
- range()二元元组遍历
- redis集群搭建
- LightOJ 1079Just another Robbery &&HDU 2955Robberies 01背包
- 统计,优化(Counting Intersections,HDU 5862)
- mkdir -p 参数
- Python面向对象编程(1):基类与__init__()方法
- 4.1 元器件的选型和设计
- 应用JavaScript(二):增强表单的可用性
- 计算几何