python list comprehensions; compressing a list of lists?

后端 未结 13 1994
名媛妹妹
名媛妹妹 2020-11-30 01:49

guys. I\'m trying to find the most elegant solution to a problem and wondered if python has anything built-in for what I\'m trying to do.

What I\'m doing is this. I

13条回答
  •  没有蜡笔的小新
    2020-11-30 02:21

    import itertools
    x=[['b11','b12'],['b21','b22'],['b31']]
    y=list(itertools.chain(*x))
    print y
    

    itertools will work from python2.3 and greater

提交回复
热议问题