我有一个列表中的python字符串列表。你知道吗
我想在列表中的每个字符串上调用split方法,并将结果存储在另一个列表中,而不使用循环,因为列表非常长。你知道吗
编辑1 这里有一个例子
input = ["a,the,an","b,b,c","people,downvoting,it,must,think,first"]
output [["a","the","an"],["b","b","c"],["people","downvoting","it","must","think","first"]]
用于拆分的分隔符是“,”
有什么窍门吗?你知道吗
如果您想要一个平面列表,而不是列表列表:
使用列表理解。你知道吗
不知道它的性能是否比
for
循环好,但你可以这样做。你知道吗如果你想把所有的东西都列在一个列表里,你可以试试这个(不知道效率有多高)
相关问题 更多 >
编程相关推荐