你可以使用itertools内置模块https://docs.python.org/3.8/library/itertools.html#itertools.product中的product
输入迭代的笛卡尔积。
大致相当于生成器表达式中的嵌套 for 循环。为了
例如,product(A, B) 返回与 ((x,y) for x in A for y in
B)。
from itertools import product
arr1 = ["test", "what", "334"]
arr2 = ["_", "-", "#", "*", "()", "$"]
arr3 = ["adf", "ngdda"]
results = ["".join(result) for result in product(arr1, arr2, arr3)]
print(len(results))
print(results)
输出
36
['test_adf', 'test_ngdda', 'test-adf', 'test-ngdda', 'test#adf', 'test#ngdda', 'test*adf', 'test*ngdda', 'test()adf', 'test()ngdda', 'test$adf', 'test$ngdda', 'what_adf', 'what_ngdda', 'what-adf', 'what-ngdda', 'what#adf', 'what#ngdda', 'what*adf', 'what*ngdda', 'what()adf', 'what()ngdda', 'what$adf', 'what$ngdda', '334_adf', '334_ngdda', '334-adf', '334-ngdda', '334#adf', '334#ngdda', '334*adf', '334*ngdda', '334()adf', '334()ngdda', '334$adf', '334$ngdda']