
elif是else if的简写。else和elif语句也可以叫做子句,因为它们不能独立使用,两者都是出现在if、for、while语句内部的。else子句可以增加一种选择;而elif子句则是需要检查更多条件时会被使用,与if和else一同使用。
实例:
people = 30
cars = 40
buses = 15
if cars > people:
print( "We should take the cars.")
elif cars < people:
print ("We should not take the cars.")
else:
print ("We can't dicide.")
if buses > cars:
print ("That's too many buses.")
elif buses < cars:
print ("Maybe we could take the buses.")
else:
print ("We still can't decide.")
if people > buses:
print ("Alright, let's just take the buses.")
else:
print ("Fine, let's stay home then.")运行结果:

思乐微信商城微分销系统是以.net+access/mssql进行开发的微信分销系统。基于微信朋友圈的传播,是打造以分销商为中心的全新微信分销体验。让粉丝实时有效的获取朋友圈流量并快速分享购买分佣。因为是基于微信,所以要在微信上体验才更好。关注我们的微信核心功能:1、自动提示用户关注微信,解决一般程序无关注微信公众号的过程2、只要通过链接进一次,不过好久注册,什么方面注册,只要是用微信注册的,都会算
更多Python相关技术文章,请访问Python教程栏目进行学习!
立即学习“Python免费学习笔记(深入)”;










