Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个类对象列表,比如鸟类。每只鸟都有一种颜色。我想从这个鸟类列表中轻松获得一组鸟类颜色。最快、最有效的方法是什么?
那可能是:
set(bird.color for bird in birds)
{bird.color for bird in birds}
Python 2.7 或 3.x