0

I have the following Python code:

units_abilities = (Session.query(UnitsAbility.id)
                          .filter(UnitsAbility.unit_id == unit.id)
                          .all())
print units_abilities

When I run it, i get [(1L,), (2L,)], but I need list, not list of tuples

How can I get units_abilities like [1L, 2L,]?

I am using SQLAlchemy 0.7.3 and Python 2.7

4

1 回答 1

0

尝试以下操作:

>>> units_ability = [(1L,), (2L,)] # units_abilities = (Session....all())
>>> [x for (x,) in units_ability]
[1L, 2L]
于 2013-09-01T12:19:37.600 回答