Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 313 Bytes

58.md

File metadata and controls

20 lines (13 loc) · 313 Bytes
@author jackzhenguo
@desc 
@date 2019/3/23

58 operator使用举例

from operator import (add, sub)


def add_or_sub(a, b, oper):
    return (add if oper == '+' else sub)(a, b)


add_or_sub(1, 2, '-')  # -1
[上一个例子](57.md) [下一个例子](59.md)