Python 遍历字符串的 For 循环

遍历字符串

字符串也是可迭代对象,它们包含一系列字符:

实例

遍历单词 "banana" 中的字母:

for x in "banana":
  print(x)

亲自试一试

相关页面

教程:

术语: