2024-05-23 18:04:27 发布
网友
如何在Python中连接两个大小相同的列表
示例:
listname = ['jhon', 'maria', 'peter'] listage = [18, 25, 14]
预期结果:
finallist = [['jhon',18], ['maria',25], ['peter', 14]]
您可以尝试:
>>> listname = ['jhon', 'maria', 'peter'] >>> listage = [18, 25, 14] >>> zip(listname, listage) <zip object at 0x000001E4734B6888> >>> list(zip(listname, listage)) [('jhon', 18), ('maria', 25), ('peter', 14)]
您可以尝试:
相关问题 更多 >
编程相关推荐