1. 程式人生 > >python的流控語句

python的流控語句



1,while
   while True:
     print(‘do something’)
     .....
2,if  elif  else
  if x<10:
    print('a')
  elif x<100:
    print('b')
  else:
    print('c')
    
3,for
  for  i in range(0,10)
    print(i)
4,break
  while True:
    if n>100:
      break
    else:
      n=n+1
5,continue
  for i in range(0,1000):
    if i%3==0:
      continue
    else:
      print('x')
6,pass
  def f0():
    pass