您现在的位置是:课程教程文章
python用什么遍历list?
2023-12-18 17:40课程教程文章 人已围观
在python中,遍历list使用for循环。python中的list对象是可迭代对象,所以可以直接用for循环遍历list中的每一个数据。
python中的list对象是可迭代的所以可以直接使用for循环遍历list中的所有数据。
ls = [1, 2, 3, 4] for i in ls: print(i)
结果是:
1 2 3 4
课程教程:python用什么遍历list?推荐课程:Sublime编辑器(Corey Schafer)
上一篇:python描述符是什么意思
下一篇:没有了