如何使用列表推导式获取值内键对值的值?

How can I reach values of a key pair value within a value with list comprehensions?

我想遍历“价格”字典(我的意思是 t1 或 t2,而不是 e1 或 e2)并通过使用列表推导来获取它们的值

def combine2(ticks: Mapping[str, Generator[Tick, None, None]]) -> None:
    [????]

t1 = Tick(time=datetime.now(), prices={'i1': 11.11, 'i2': 12.12, })
t2 = Tick(time=datetime.now(), prices={'i1': 13.13, 'i2': 14.14, })
t3 = Tick(time=datetime.now(), prices={'i1': 15.15, 'i2': 16.16, })

combine2({'e1': t1, 'e2': t2, 'e3': t3})

感谢您的提问,试试这个:

def combine2(ticks: Mapping[str, Tick]) -> None:
    prices = [price for tick in ticks.values() for price in tick.prices.values()]
    print(prices)