我想使用列表推导来实现与下面相同的结果。有人可以帮忙吗?
s1 = "one two three four"
s2 = "five six seven eight"
my_list = []
l1 = s1.split()
l2 = s2.split()
my_list.append(l1)
my_list.append(l2)
print(my_list)
输出:
[['one', 'two', 'three', 'four'], ['five', 'six', 'seven', 'eight']]
答案 0 :(得分:0)
使用您想要的所有字符串列表
lst_of_s = [s1,s2,s3]
result = [i.split() for i in lst_of_s]