如果妳祈求心灵的平和与快乐,就去信仰上帝!如果妳希望成为一个真理的门徒,探索吧!! -- 尼采
I can calculate the motions of havenly bodies, but not the madness of people. -- Newton
You have to be out to be in.

搜索引擎

Java, Web, Searching Engine

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  24 随笔 :: 25 文章 :: 27 评论 :: 0 Trackbacks

Control Flow Statements


If-else


if expression:
    statement(s)
elif expression:
    statement(s)
elif expression:
    statement(s)
...
else:
    statement(s)


Python does not have a switch statement.

while expression:
    statement(s)


for target in iterable:
    statement(s)


Python provides built-in functions range() and xrange() to generate and return integer sequences.

range(x) returns a list whose items are consecutive integers from 0 (included) up to x (excluded).
range(x, y) returns a list whose items are consecutive integers from x (included) up to y (excluded).


List comprehensions

[ expression for target in iterable lc-clauses ]
[x+1 for x in some_sequence if x>23]
[x+y for x in alist for y in another]


posted on 2007-11-24 20:58 专心练剑 阅读(172) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。