📜  cursor.fetchall() 到列表 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:27.796000             🧑  作者: Mango

代码示例1
And what about list comprehensions? If result is ((123,), (234,), (345,)):

>>> row = [item[0] for item in cursor.fetchall()]
>>> row
[123, 234, 345]

If result is ({'id': 123}, {'id': 234}, {'id': 345}):

>>> row = [item['id'] for item in cursor.fetchall()]
>>> row
[123, 234, 345]

--César