您的位置:首页 > 编程语言 > Python开发

python的if语句

2016-06-12 22:42 330 查看
a=[2,3,4]
if a[0]>3:
print("this is run")
elif a[2]==4:
print "this is four"
else:
print "no run"

b=(1,2,3,4)
if b[0]>2:
print "this is one step"
else:
print "this is two step"
# output
# this is four
# this is two step
语法中语句的尾部都加了冒号。这是感觉和C中不同之处。而且条件表达式不用括号。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: