python 如何将两个列表按照这个格式形成一个新的列表


需求:
要求将两个列表按照这个格式形成一个新的列表【1,a,2,b,3,c】

方式一

lst1 = [1,2,3]
lst2 = [a,b,c]

a = []
for i,j in zip(lst1, lst2):
    a.append(i)
    a.append(j)
print(a)

方式二

lst1 = [1,2,3]
lst2 = [a,b,c]

a = list(map(lambda x,y: (x,y), lst1, lst2))
print([j for i in a for j in i])

方式三


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM