您可以使用distinct()方法来获取ceduan项不同的数据。下面是一个示例代码:

from flask import g
from your_app.models import HandleGaochabiaoMatchs
from sqlalchemy import and_

ceduan_list = HandleGaochabiaoMatchs.query.filter(
    and_(
        HandleGaochabiaoMatchs.user_id == g.user.user_id,
        HandleGaochabiaoMatchs.zhenduans
    )
).with_entities(HandleGaochabiaoMatchs.ceduan).distinct().all()

# 提取不同的ceduan项
distinct_ceduan_list = [item[0] for item in ceduan_list]

在上面的代码中,ceduan_list是一个包含所有不同的ceduan项的列表。您可以通过遍历这个列表来访问每个不同的ceduan项。如果您只对ceduan项的值感兴趣,可以使用列表推导式来提取这些值,保存在distinct_ceduan_list中。

请注意,您需要将your_app.models替换为您的应用程序的模型文件的路径,并确保数据库中有名为HandleGaochabiaoMatchs的模型类


原文地址: http://www.cveoy.top/t/topic/ixI5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录