python 笔迹1

#coding:utf-8
'''
Created on 2015.3.22

@author: ZQM
'''
from __future__ import division

def jia(x,y):
    return x+y;

def jian(x,y):
    return x-y

def cheng(x,y):
    return x*y;

def chu(x,y):
    return x/y;

operator = {'+':jia, '-':jian, '*':cheng, '/':chu};

#print operator["/"](3,2) ;

def f(x,o,y):
    print operator.get(o)(3,2)

f(3,'-',2) 

 

posted @ 2015-03-22 18:51  奔雷手  阅读(178)  评论(0编辑  收藏  举报