您可以使用案例表达
from sqlalchemy import case @func.expression def func(cls): return case( [ (cls.some_column == True, cls.true_column * cls.amount), ], else_=cls.false_column * cls.amount )