python 将一个字符list的列表扁平化成了一个list

a=[['app','ap','ade'],['er'],['bcc','brt']]

将这么一个list 转换成 a2=['app','ap','ade','er','bcc','brt']

做法:a2=[x for tup in a for x in tup]

 

猜你喜欢

转载自www.cnblogs.com/cheng-cheng/p/10027446.html