我有一份清单清单mainList.我希望附上一个subList,但只有第2,第3,第4,第5和第7项.
for subList in file:
mainList.append(subList[#items 2,3,4,5,7])
Run Code Online (Sandbox Code Playgroud)
除此之外还有办法吗?
for subList in file:
temp = []
for item in subList[1:]:
if #item not the 6th item:
temp.append(item)
mainList.append(temp)
Run Code Online (Sandbox Code Playgroud)
我可以在没有temp列表的情况下执行此操作,并且嵌套的for循环附加此列表吗?