我有一个简单的类Foo
,由:
class Foo:
def __init__(self, bar: list):
self.bar = bar
以及此类foos
的实例实例的数组:
foos = []
foos.append(Foo(bar=[1, 2]))
foos.append(Foo(bar=[3, 4]))
foos.append(Foo(bar=[5, 6]))
我想要一个bars
的数组,如下所示:
bars = [[1, 2], [3, 4], [5, 6]]
请问该如何处理?
答案 0 :(得分:2)
您可以使用简单的list comprehension:
PrintDocument pd = new PrintDocument();
CountdownEvent countdown = new CountdownEvent(this.PathsJPG.Length);
for (int i = 0; i < this.PathsJPG.Length; i++) {
currentpath = getCurrentPath(i);
pd.PrintPage += PrintPage;
pd.EndPrint += (o,e) => { countdown.Signal(); }
pd.Print();
}
countdown.Wait();