从 n 个整数列表(可能长度不等)进行所有可能的 n 长度排列

Make all possible n length permutations from n lists of integers (of possibly unequal length)

示例:

list1 = [0,1,2]
list2 = [0,1]
list3 = [0,1,2,3]

那么排列将是:

0,0,0
0,0,1
0,0,2
0,0,3
0,1,0
0,1,1
0,1,2
0,1,3
1,0,0
1,0,1
1,0,2
1,0,3
1,1,0
1,1,1
1,1,2
1,1,3

...以此类推 3 x 2 x 4 = 24 个排列。

列表的数量不一定是 3(它们可以是任何数字 n)并且顺序很重要,因此 0,0,1 与 0,1,0 不同。

我知道我可能不得不以某种方式使用 itertools,但不确定如何处理。我不能只做三个嵌套循环,因为列表的数量不同。

这是 this question 的变体,但列表的数量和顺序很重要。

感谢任何帮助或提示。谢谢

list1 = [0,1,2]
list2 = [0,1]
list3 = [0,1,2,3]
listOfLists = [list1,list2,list3]
for list in itertools.product(*listOfLists):
    print(list)