小编gar*_*rth的帖子

将"元组列表"转换为平面列表或矩阵

使用Sqlite,"select..from"命令返回结果"output",其打印(在python中):

>>print output
[(12.2817, 12.2817), (0, 0), (8.52, 8.52)]
Run Code Online (Sandbox Code Playgroud)

它似乎是一个元组列表.我想在一个简单的1D数组中转换"输出"(我猜的是Python中的列表):

[12.2817, 12.2817, 0, 0, 8.52, 8.52]
Run Code Online (Sandbox Code Playgroud)

或2x3矩阵:

12.2817 12.2817
0          0 
8.52     8.52
Run Code Online (Sandbox Code Playgroud)

通过"output [i] [j]"读取

flatten命令不能完成第一个选项的工作,我不知道第二个选项...... :)

你能给我一个提示吗?有些事情很快就会很好,因为真正的数据要大得多(这里只是一个简单的例子).

python tuples list

57
推荐指数
8
解决办法
3万
查看次数

标签 统计

list ×1

python ×1

tuples ×1