扫码关注官方订阅号
Python里怎么实现switch case?
闭关修行中......
python没有switch case。switch case从逻辑上来说像是一个hash表。你可以使用python的字典来实现类似功能。
switch_dict = { "case_foo": foo(), "case_bar": bar(), ... } switch_dict.get("case", "default_case")()
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
python没有switch case。switch case从逻辑上来说像是一个hash表。你可以使用python的字典来实现类似功能。