python for循环方式
# 能够获取对应的索引
for index in range(len(photo_url_list)):
photo_url = 'https://pic.netbian.com'+photo_url_list[index]
迭代的方式
range(len(list)) 这里用到了range()和len()两个函数
函数:len()
1:作用:返回字符串、列表、字典、元组等长度
2:语法:len(str)
3:参数:
str:要计算的字符串、列表、字典、元组等
4:返回值:字符串、列表、字典、元组等元素的长度
函数:range()
python内置range()函数的作用是什么?它能返回一系列连续增加的整数,它的工作方式类似于分片,可以生成一个列表对象。range函数大多数时常出现在for循环中,在for循环中可做为索引使用。其实它也可以出现在任何需要整数列表的环境中,在python 3.0中range函数是一个迭代器。
>>> range(4)
[0, 1, 2, 3] #python 返回值