我是python新手,我一直在解决这个问题。我使用一个代码,由“数据形状”创建,它从GUI中指向的TreeView中收集选定的标记
if f.GetType() == TreeView:
ls = []
nds = f.Nodes[0]
iterateThroughNodes(nds,ls)
它使用递归函数“IterateThrowNodes()”返回一个列表“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']]
你能为代码更改提供建议吗
目前没有回答
相关问题 更多 >
编程相关推荐