How python links traverable objects
This article mainly introduces how python links traversal objects, the article is very detailed, has a certain reference value, interested friends must read it!
Link traverable object (itertools.chain)
> a = [1,2,3,4] > > for p in itertools.chain (itertools.combinations (a, 2), itertools.combinations (a, 3)): Print p. (1,2) (1,3) (1,4) (2,3) (2,4) (3,4) (1,2,3) (1,2,4) (1,3,4) (2,3,4) > > for subset in itertools.chain.from_iterable (itertools.combinations (a, n) for n in range (len (a) + 1). Print subset... () (1,) (2,) (3,) (4,) (1, 2) (1, 3) (1, 4) (2, 3) (2, 4) (3, 4) (1, 2, 3) (1, 2, 4) (1, 3, 4) (2, 3, 4) (1, 2, 3, 4) (1, 2, 3, 4) above are all the contents of the article "how python links can be traversed objects". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!