How to realize the Cartesian Product of two lists by python
This article mainly introduces how python realizes the Cartesian product of two lists, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Cartesian product of two lists
>>> for p in itertools.product([1, 2, 3], [4, 5]):(1, 4)(1, 5)(2, 4)(2, 5)(3, 4)(3, 5)>>> for p in itertools.product([0, 1], repeat=4):... print ''.join(str(x) for x in p)... 00000100100011010001010110011001100101101101101110111111 Thank you for reading this article carefully. I hope that the article "how python realizes the Cartesian product of two lists" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!