day2-emloyee information

#!/usr/bin/env python
#coding:utf-8
#__author__:Bing

import sys,json
import time,datetime

account = [{"name":"Wang","sex":"male","job":"Designer","email":"test@test.com","address":"New street","phone":"110","age":"32"},\
           {"name":"Tang","sex":"Female","job":"Painter","email":"test1@test.com","address":"East street","phone":"120","age":"31"},\
           {"name":"Hang","sex":"Female","job":"Driver","email":"test2@test.com","address":"West street","phone":"119","age":"30"},\
           ]

def info(keyword,type):
    for i in account:
        try:
            if str(keyword) == i[str(type)]:
                return [i["name"],i["sex"],i["job"],i["email"],i["address"],i["phone"],i["age"]] 
            else:
                return 0#sys.exit("\033[1;31;47mThere's no information you're looking for.\033[0m")
        except:
            return 1#print "\033[1;31;47mYou input error!please input again...\033[0m"
                
def search():
    type = raw_input("please enter your search type(name/job/sex/age):")
    keyword = raw_input("please enter your search keyword(Wang/Designer/Female/18):")
    result = info(keyword, type)
    if result and result != 1:
        print "\033[1;34;47mThis is information you're looking for:\033[0m"
        print "name:"+result[0]
        print "sex:"+result[1]
        print "job:"+result[2]
        print "email:"+result[3]
        print "address:"+result[4]
        print "phone:"+result[5]
        print "age:"+result[6]
        
    '''
    test
    '''
     
search()


转载于:https://my.oschina.net/u/2393235/blog/668757

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值