Python中elif简单示例

#-*-coding:utf-8-*-
import sys
def Main():
	x=5
	print "OK"
	if x==2:
		print "TWO"
	elif x==3:
		print "three"
	elif x==4:
		print "four"
	else:
		print "wrong number"
	
	#用dict
	num={1:"one",2:"two"}
	try:
		print num[x]
	except KeyError:
		print "wronr num!"
		
if __name__=="__main__":
	Main()

你可能感兴趣的:(Python)