我是python的新手,我遇到了问题。我使用由“数据形状”创建的代码,该代码从TreeView中收集GUI中指向的选定标签。
if f.GetType() == TreeView:
ls = []
nds = f.Nodes[0]
iterateThroughNodes(nds,ls)
它使用递归函数“ iterateThroughNodes()”返回列表“ ls”中的所有标签
def iterateThroughNodes(collection,li):
if hasattr(collection,'Nodes'):
ntest = collection.Nodes
if len(ntest) > 0:
for i in ntest:
iterateThroughNodes(i,li)
else:
if collection.Checked:
li.append(collection.Tag)
return li
但是如何将值保存在列表列表中,其中数据将根据它们在树中的位置进行分组。
现在我有这个:
ls = [23,45,'reinforcement type', 'length']
我需要:
ls = [[23,45],['reinforcement type', 'length']]
您能为代码更改提供建议吗?