椿雪

python用dict字典映射相当于switch语句
# 采用dict映射
def print_A():
    print("A")
def print_B():
    print("A")
def print_C():
    print("A")

score  = 90
# switch  = {
#     90:print_A(),
#     80:print_C()
# }

switch = {
    90:lambda :print_A()
}

switch[score]()

 

posted on 2022-02-14 10:31  椿雪  阅读(34)  评论(0)    收藏  举报