正在加载图片...
五、遍历列表 遍历列表可以逐个处理列表中的元素,通常使用「or循环和 whil循环来实现。第一种遍历方法隐藏了列表的长度,操 作较为便利,第二种遍历方法侧使用ln0函数计算出列表 numbers的长度后进行遍历操作,其中range0函数返回的 是从0到numbers长度的数值序列。 用for循环遍历列表 并遍历列表 Ist=['primary school,'secondary school','high school,'college'] for item in Ist: print(item,end,"】 运行结果 primary school,secondary school,high school,college, 五、遍历列表  遍历列表可以逐个处理列表中的元素,通常使用for循环和 while循环来实现。第一种遍历方法隐藏了列表的长度,操 作较为便利,第二种遍历方法则使用len()函数计算出列表 numbers的长度后进行遍历操作,其中range()函数返回的 是从0到numbers长度的数值序列。 用for循环遍历列表 #遍历列表 lst=['primary school','secondary school','high school','college'] for item in lst: print(item,end=",") 运行结果: primary school,secondary school,high school,college
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有