python - 将列表中的字符串拆分为多个字符串

时间:2013-12-12 07:17:35

标签: python

我有一个清单

strings = ['abc efg hijklmn aaaaa']

我试图将其拆分为多个字符串列表:

strings = ['abc', 'efg', 'hijklmn', 'aaaaa']

我该怎么做呢?看起来很琐碎

3 个答案:

答案 0 :(得分:3)

strings = ['abc efg hijklmn aaaaa']
strings = strings[0].split()

答案 1 :(得分:1)

即使原始列表中有更多字符串,这也会有效。

strings = ['abc efg hijklmn aaaaa', 'abc efg hijklmn aaaaa']
print [item for current in strings for item in current.split()]

答案 2 :(得分:0)

otherlist = []
for thing in strings:
    otherlist.extend(thing.split(" "))
strings = otherlist