我的问题如下,我有一个名为
但是实际上我得到的是
crave=['word1','word2','word3'....'wordx']
的数组,我想将其转换为ITEM=[['word1','word2','word3'],['word4','word5','word6']等]
。我使用了以下代码。buff=[['none','none','none']]
n=10
ITEM=[]
i=0
while 1>0 :
buff[0][0]=crave[i]
buff[0][1]=crave[i+1]
buff[0][2]=crave[i+2]
ITEM.insert(len(ITEM),buff[0])
i=i+3
if i>n:
break
但是实际上我得到的是
[['wordx-2','wordx-1','wordx'],['wordx-2','wordx-1','wordx'],['wordx-2','wordx-1','wordx']等等]
,为什么会这样呢? :(