第四章 条件与循环

1.条件语句

if 表达式:

  代码块

elif 表达式:

  代码块

else:

  代码块

2.for循环

for 迭代变量 in 可迭代对象:

  代码块

for year in range(2000,2019):

  print('%s年是%s' %(year, ***))

3.while循环

while 表达式:

  代码块

import time

num = 5

while True:

  print('a')

  time.sleep(1)

  if num > 10:

    break  #continue

4.循环与判断的嵌套

猜你喜欢

转载自www.cnblogs.com/wcsan/p/9388054.html