2014-04-17 67 views
1

我想将项目追加到列表的列表中,但是我得到的是extend()的等效项。在Python中将多个项目追加到列表中

doc = __doc__ 
result = [] 

collector = FilteredWorksetCollector(doc) 
user_worksets = collector.OfKind(WorksetKind.UserWorkset) 
for i in user_worksets: 
    result.append(i.Name) 
    result.append(i.Kind) 
OUT = result 

我想得看起来像这样的列表:[名字,名字,名字],[亲切,慈祥,善良]

谢谢你,

回答

4
OUT = [[i.Name for i in user_worksets], [i.Kind for i in user_worksets]] 
+0

这很棒!谢谢。 – konrad

相关问题