python流程控制与逻辑运算符

python流程控制与逻辑运算符

作者:LAMP小白  点击:1586  发布日期:2013-10-16 23:56:34  返回列表

流程控制

if expression:

   statement(s)


python使用缩进作为其语句分组的方法


if expression:

   statements

else:

   statements


if expression:

   statements

elif expression:

   statements

elif expression:

   statements

else:

   statements


逻辑运算符

and or not


#!/usr/bin/python
if True:
    print 'true'
if False:
    print 'true'
else:
    print 'false'
        
a=3
if 1==a:
    print 'a=1'
elif 2==a:
    print 'a=2'
elif 3==a:
    print 'a=3'
else:
    print 'out of range'
if True and False:
    print 'true'
else:
    print 'false'
        
if False or False or True:
    print 'true'
if not False:
    print 'not false'




上一篇:Python数据类型-字典 下一篇:快递查询API
0