python---控制流match case语法

- 控制流概览

1. match 语句

 def errors(status):
    match status:
        case 400:
            pass
        case _:
            pass
class Point:
    x: int
    y: int
def where_is(point):
    match point:
        case Point(x=0, y=0):
            print("Origin")
        case Point(x=0, y=y):
            print(f"Y={y}")
        case Point(x=x, y=0):
            print(f"X={x}")
        case Point():
            print("Somewhere else")
        case _:
            print("Not a point")

你可能感兴趣的:(cython为python扩展,python)