使用Itertools和Python生成二进制表

所以这就是我的尝试
list(itertools.combinations_with_replacement('01', 2))
但这会产生[('0','0'),('0','1'),('1','1')] 我仍然需要一个('1','0')元组,有没有办法让itertools也做组合和命令?     
已邀请:
使用
list(itertools.product(*["01"] * 2))
代替。     
要使用自身的笛卡尔积,请使用
itertools.product("01", repeat=2)
这将为您提供所有可能的组合。     
该程序生成从1到100的数字,然后将其转换为二进制
a=0
while a<100:
 a=a+1
 print a,"=",bin(a)
    

要回复问题请先登录注册