Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 457 Bytes

循环_20170622.md

File metadata and controls

14 lines (12 loc) · 457 Bytes

Python 的循环有两种,一种是 for...in 循环
Python 提供一个 range() 函数,可以生成一个整数序列,再通过 list() 函数可以转换为 list。

>>> list(range(5))
[0, 1, 2, 3, 4]

第二种循环是 while 循环

  • break 在循环中,break 语句可以提前退出循环。
  • continue 在循环过程中,也可以通过 continue 语句,跳过当前的这次循环,直接开始下一次循环。