Transform “list of tuples” into a flat list or a matrix

后端 未结 9 2009
北荒
北荒 2020-11-27 13:17

With Sqlite, a \"select..from\" command returns the results \"output\", which prints (in python):

>>print output
[(12.2817, 12.2817), (0, 0), (8.52, 8.         


        
9条回答
  •  猫巷女王i
    2020-11-27 13:40

    By far the fastest (and shortest) solution posted:

    list(sum(output, ()))
    

    About 50% faster than the itertools solution, and about 70% faster than the map solution.

提交回复
热议问题