Python 3.10版本在2021年10月发布,新增了match-case语法。其实就是对应别的开发语言的switch-case语法。
例子
def http_error(status):
match status:
case 400:
print("Bad request")
case 404:
print("Not found")
case 418:
print("I'm a teapot")
case _:
print("Something's wrong with the internet")
标签:case,status,Python,语法,print,match From: https://www.cnblogs.com/live41/p/17277139.html