4.6 for循环的基础语法

一、for循环基础

  1. for循环是一种轮询机制,是对一批内容逐个处理

  2. 可以循环的变量为:字符串换、列表、元组等

  3. 格式:

    for 临时变量 in 变量:
      	处理内容
  4. 例子

    name = "Snow"
    
    for s in name:
        print(s)
    

Last updated

Was this helpful?