Python for循环可以遍历任何序列的项目,如一个列表或者一个字符串。本文主要介绍Python for循环遍历字符串。

Python 常用术语

1、for循环遍历字符串

即使字符串是可迭代的对象,它们也单个字符组成:

例如:

遍历 "cjavapy” 字符串中的字母:

for x in "cjavapy":
    print(x)

相关文档:

Python for循环教程

Python for循环

Python for循环遍历字符串

Python for break语句

Python for continue语句

Python for循环使用range()函数

Python for 循环中的else

Python for循环嵌套

Python for循环中的pass

Python 常用术语

推荐文档

相关文档

大家感兴趣的内容

随机列表