2019-03-17
阅读量:
879
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应用程序时,可使用切片来分页显示信息。






评论(0)


暂无数据
推荐帖子
2条评论
6条评论
7条评论