【发布时间】:2013-02-02 14:47:10
【问题描述】:
在 Python 中,如何获取 n 二进制值 0 和 1 的所有组合?
比如n = 3,我想拥有
[ [0,0,0], [0,0,1], [0,1,0], [0,1,1], ... [1,1,1] ] #total 2^3 combinations
我该怎么做?
【问题讨论】:
-
@eumiro,我认为我的问题也等同于这个问题,stackoverflow.com/questions/3252528/…,但这个答案给出了一个字符串而不是一个列表。
标签: python list math python-2.7