我有一个像这样的字符串列表:
The method min() in the type IntStream is not applicable for the
arguments (Comparator.comparingDouble((<no type> i) -> Math.sin(i)))
我想扩展mylist = ["This is quite possibly the worst movie ever made. Even my 4 year old hated it and wanted to leave.", "I hate this movie."]
的维度:
mylist
我该怎么做?
答案 0 :(得分:1)
list_of_strings = ["string one", "string two", "etc."]
list_of_lists = [x.split() for x in list_of_strings]
答案 1 :(得分:1)
>>> mylist = ["This is quite possibly the worst movie ever made. Even my 4 year old hated it and wanted to leave.", "I hate this movie."]
>>> [[x] for x in mylist]
[['This is quite possibly the worst movie ever made. Even my 4 year old hated it and wanted to leave.'], ['I hate this movie.']]
答案 2 :(得分:0)
这个怎么样?
import itertools
str = ["This is quite possibly the worst movie ever made. Even my 4 year old hated it and wanted to leave.", 'I hate this movie.']
result = list(itertools.chain.from_iterable([i.split() for i in str ]))
但如果我是你,我会用更多的行来写它以使其可读。