猿问
Python里怎么实现switch case?
Python里怎么实现switch case?
守着一只汪
浏览 703
回答 5
5回答
人到中年有点甜
python没有switch case。switch case从逻辑上来说像是一个hash表。你可以使用python的字典来实现类似功能。 switch_dict = { "case_foo": foo(), "case_bar": bar(), ... } switch_dict.get("case", "default_case")()
0
0
0
哔哔one
用字典可以实现
0
0
0
随时随地看视频
慕课网APP
相关分类
Python
我要回答