match case
Python구조적-패턴-매칭-파이썬에서-switchcase문
status = 200 # if status == 200: # print("OK!") # elif status == 300: # print("Err") # else: # print("unknown") # switch py=3.10 match status: case 200: print("OK!") case 300 | 400: print("Err") case _: print("unknown")
switch case와 달리, 패턴 매칭
def draw(point) \tmatch point: case(x, y): print(f'x:{x}, y:{y}') case(x, y, z): print(f'x:{x}, y:{y}, z:{z}') draw(10,20,30) draw(10,20)
...