如何在 Python 中按序列索引进行迭代?
pythonserver side programmingprogramming更新于 2025/8/10 14:36:17
Python 中的序列对象是项目的有序集合。序列中的每个项目(列表、元组和字符串)都可以通过从 0 开始的索引访问。
遍历列表中的元素
>>> L1=[10,20,30,40,50] >>> for i in range(len(L1)): print (L1[i]) 10 20 30 40 50
从字符串中一次切出一个字符
>>> string ='TutorialsPoint' >>> for i in range(len(string)): print (string[i]) T u t o r i a l s P o i n t
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

