for(int a = 5; a > 0 ; a--){ for(int b = 1; b <= a; b++){ System.out.print(" "); } for(int c = 5; c >= a; c--){ System.out.print("* "); } System.out.println(" "); } for(int a = 4; a > 0 ; a--){ for(int d = 1; d &g
咱们直接先来看for循环.Python for循环可以遍历任何序列的项目,如一个列表或者一个字符串.然后再来看一下它的语法结构: for iterating_var in sequence: statements(s) 这是他的工作流程图: 来,咱们看实例来: #!/usr/bin/python # -*- coding: UTF-8 -*- for letter in 'Python': # 第一个实例 print '当前字母 :', letter fruits
1.while 循环语句 #!/usr/bin/env python # -*- coding:utf-8 -*- import time bol = True while bol: print '1' time.sleep(1) bol = False print 'hello,world!' 2.无限的输出数字 #!/usr/bin/env python # -*- coding:utf-8 -*- import time n = 0 while True: n = n + 1 time.s