こんにちは、このコードは python 2.7 では動作しますが、python 3 では動作しません
import itertools
def product(a,b):
return map(list, itertools.product(a, repeat=b)
print(sorted(product({0,1}, 3)))
それは出力します
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
Python 2.7では、しかしPython 3では、0x028DB2F0でマップオブジェクトを提供します。これをPython 3で機能するように変更する方法を知っている人はいますか?出力はPython 2.7と同じままです