$ ls ~yifei/notes/

Python 中复合的 list comprehension

Posted on:

Last modified:

Python 中的 list comprehension 可以复合

[x for li in lists for x in li if x]

就相当于

[x
    for li in lists
        for x in li
             if x]

© 2016-2022 Yifei Kong. Powered by ynotes

All contents are under the CC-BY-NC-SA license, if not otherwise specified.

Opinions expressed here are solely my own and do not express the views or opinions of my employer.