编程语言提供了各种控制结构,允许更复杂的执行路径。循环语句允许我们执行一个语句或语句组多次
Python 循环语句 语法
Python提供了for循环和while循环(在Python中没有do..while循环)
Python 循环语句 示例
while循环语句
#!/usr/bin/python count = 0while (count < 9): print 'The count is:', count count = count + 1 print "Good bye!"
for 循环语句
#!/usr/bin/python# -*- coding: UTF-8 -*- for letter in 'Python': # 第一个实例 print '当前字母 :', letter fruits = ['banana', 'apple', 'mango']for fruit in fruits: # 第二个实例 print '当前水果 :', fruit print "Good bye!"
热门推荐
- python如何读取excel表数据
- isinstance在python中的意思是什么?
- python怎么样输出九九乘法表
- 简单python代码类型有哪些?
- python如何产生10个不同的随机数
- python语言语句块的标记是什么?