2019-03-17
阅读量:
1046
Python如何遍历切片?
要遍历列表的部分元素,可在for 循环中使用切片。
players = ['charles','martina','michael','florence','eli']
print("Here are the first three players in my team:")
for player in players[0:3]:
print(player.title())
>>>Here are the first three players in my team:
>>>Charles
>>>Martina
>>>Michael处理数据时,可使用切片来进行批量处理;编写Web应用程序时,可使用切片来分页显示信息。
3.2276
1
2
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
2条评论
6条评论
7条评论

