Powersets in Python using itertools
问题 I\'m trying to create a powerset in Python 3. I found a reference to the itertools module, and I\'ve used the powerset code provided on that page. The problem: the code returns a reference to an itertools.chain object, whereas I want access to the elements in the powerset. My question: how to accomplish this? Many thanks in advance for your insights. 回答1: itertools functions return iterators, objects that produce results lazily, on demand. You could either loop over the object with a for loop