设为首页 加入收藏

TOP

Python实现switch功能
2014-11-24 01:09:12 来源: 作者: 【 】 浏览:5
Tags:Python 实现 switch 功能

Python实现switch功能


#!/usr/bin/env python
# Filename: switch.py
# Author: zhangliang - z_liang90@126.com
# Last modified: 2014-02-26 10:53
# Description:
from __future__ import division
def arithMetic(x,oprator,y):
result = {
'+':x+y,
'-':x-y,
'*':x*y,
'/':x/y
}
return result.get(oprator)
x = input('x:')
y = input('y:')
oprator = raw_input('oprator:')
retval = arithMetic(x, oprator, y)
print '%d %s %d = %d' % (x, oprator, y, retval)


推荐阅读:


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Java读取src下的配置文件 下一篇Linux 利用wtmp 日志记录并分析用..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: