addresses = [
            '5412 N CLARK',
            '5148 N CLARK',
            '5800 E 58TH',
            '2122 N CLARK'
            '5645 N RAVENSWOOD',
            '1060 W ADDISON',
            '4801 N BROADWAY',
            '1039 W GRANVILLE',
        ]
        counts = [0, 3, 10, 4, 1, 7, 6, 1]
        from itertools import compress
        more5 = [n > 5 for n in counts]
        print(more5)
        print(list(compress(addresses, more5)))
最终打印的结果是:
[False, False, True, False, False, True, True, False]
['5800 E 58TH', '4801 N BROADWAY', '1039 W GRANVILLE']
为什么不是'1060 W ADDISON',而是'1039 W GRANVILLE'
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
好吧,自己看错了,addresses 中有两行是连着的