Get the App
SLTechnology News&Howtos  ›  Development  › 

How python links traverable objects

Shulou Source: shulou.com Published: 2022-06-01 04:49:35 09月22日 Update

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!

Tags: Objects links content articles values interests guys buddies more knowledge industry information information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia OPPO Reno Huawei Linux