python多路分支用字典实现

来源:互联网 发布:手机越狱软件下载 编辑:程序博客网 时间:2024/06/04 23:29

#!/usr/bin/python

#-*- conding:utf-8 -*-

d0={'name':'bob',

'age':25,

'height':180,

'weight':90}

def select(select):

if select in d0:

print (d0[select])

else:

print ('no this select : %s' % select)


def help():

print('You can input from :',) #python 2.x print not newline

print(str(tuple(d0.keys())).replace('\'',''))

if __name__ == '__main__':

help()

select(raw_input()) #sugest raw_input because input will be 'string type'