假设我有这个清单:
list1 = ["I", "am", "happy", " ", "and", "fine", " ", "and", "good"]
Run Code Online (Sandbox Code Playgroud)
我想最终得到:
sublist1 = ["I", "am", "happy"]
sublist2 = ["and", "fine"]
sublist3 = ["and", "good"]
Run Code Online (Sandbox Code Playgroud)
所以,我想根据里面的空间将列表拆分成子列表list1.
python ×1