1

为什么结果不一样?

In [19]: [(yield from (1, 2)) for x in [1]]
Out[19]: <generator object <listcomp> at 0x0438B3C0>

In [20]: list(_)
Out[20]: [1, 2]

In [21]: ((yield from (1, 2)) for x in [1])
Out[21]: <generator object <genexpr> at 0x0438B480>

In [22]: list(_)
Out[22]: [1, 2, None]
4

0 回答 0