Jak*_*nov 4 python string list python-3.x
我想转换这个列表
list = ['orange','cherry,strawberry','cucumber,tomato,coconut,avocado','apple','blueberry,banana']
到
new_list = ['orange','cherry','strawberry','cucumber','tomato','coconut','avocado','apple','blueberry','banana']
有可能这样做吗?请帮我!
加入和分裂!
>>> lst = ['orange','cherry,strawberry','cucumber,tomato,coconut,avocado','apple','blueberry,banana']
>>> ','.join(lst).split(',')
['orange', 'cherry', 'strawberry', 'cucumber', 'tomato', 'coconut', 'avocado', 'apple', 'blueberry', 'banana']