【问题标题】:making sublist from sublist based on index position python [duplicate]根据索引位置python从子列表制作子列表[重复]
【发布时间】:2019-08-13 17:26:35
【问题描述】:

我有一个清单

mainlist=[[1,2,3,4],['a','b','c','d'],[4,5,6,7]]

想根据子列表中的索引位置制作子列表。输出是

finallist=[[1,'a',4],[2,'b',5],[3,'c',6],[4,'d',7]]

谢谢

【问题讨论】:

  • 完全复制 (zip(...)) 。在 SO 上使用搜索栏
  • print(list(map(list, zip(*mainlist))))

标签: python


【解决方案1】:

使用zip解包:

finallist = list(map(list, zip(*mainlist)))

【讨论】:

  • 奥斯汀:谢谢...
猜你喜欢
  • 2023-03-21
  • 2018-05-06
  • 2011-03-11
  • 2019-12-10
  • 1970-01-01
  • 2013-09-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多