"""
python 字典实现Switch Cash
"""
def func_1(str):
str = str.replace("a","")
return str
def func_2(str):
str = str.replace("a", "aa")
return str
def notify_result(type, str):
types = {
"f1" : func_1,
"f2": func_2,
}
method = types.get(type, str)
result = method(str)
return result
if __name__ == "__main__":
result1 = notify_result("f1", "abcdefg")
result2 = notify_result("f2", "abcdefg")
print("result1:",result1)
print("result2:",result2)
python 字典简单实现Switch Cash
最新推荐文章于 2023-06-24 17:30:32 发布