gpt4 book ai didi

python - 混合 3 个列表,每个列表 35 个元素 Python3

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:53 25 4
gpt4 key购买 nike

我有 3 个列表,例如

_1st = ["Qa4AJ-","Qb4AJ-","Qc4AJ-","Qd4AJ-","Qe4AJ-","Qf4AJ-","Qg4AJ-","Qh4AJ-","Qi4AJ-","QJ4AJ-","Qk4AJ-","Ql4AJ-","Qm4AJ-","Qn4AJ-","Qo4AJ-","Qp4AJ-","Qq4AJ-","Qr4AJ-","Qs4AJ-","Qt4AJ-","Qu4AJ-","Qv4AJ-","Qw4AJ-","Qx4AJ-","Qy4AJ-","Qz4AJ-","Q14AJ-","Q24AJ-","Q34AJ-","Q44AJ-","Q54AJ-","Q64AJ-","Q74AJ-","Q84AJ-","Q94AJ-"]
_2nd = ["H581A-","H582A-","H583A-","H584A-","H585A-","H586A-","H587A-","H588A-","H589A-","H58aA-","H58bA-","H58cA-","H58dA-","H58eA-","H58fA-","H58gA-","H58hA-","H58iA-","H58jA-","H58kA-","H58lA-","H58mA-","H58nA-","H58oA-","H58pA-","H58qA-","H58rA-","H58sA-","H58tA-","H58uA-","H58vA-","H58wA-","H58xA-","H58yA-","H58zA-"]
_3rd = ["KNaQ3","KNbQ3","KNcQ3","KNdQ3","KNeQ3","KNfQ3","KNgQ3","KNhQ3","KNiQ3","KNjQ3","KNkQ3","KNlQ3","KNmQ3","KNnQ3","KNoQ3","KNpQ3","KNqQ3","KNrQ3","KNsQ3","KNtQ3","KNuQ3","KNvQ3","KNwQ3","KNxQ3","KNyQ3","KNzQ3","KN1Q3","KN2Q3","KN3Q3","KN4Q3","KN5Q3","KN6Q3","KN7Q3","KN8Q3","KN9Q3"]

我想把它们混合在一起例如,我希望 Python 打印 _1st 的第一个元素、_2nd 的第一个元素和 _3rd 的第一个元素然后打印 _1st 的第一个元素与 _2nd 的第一个元素和 _3rd 的第二个元素。我需要它将每个列表中的每个元素与其他列表中的其他元素混合

我不知道“我该怎么做”。

我不确定我是否清楚地表达了我想要的内容,但我希望你能明白。

最佳答案

您要寻找的是这些列表的“笛卡尔积”

在 Python 2.6+ 中

import itertools
for element in itertools.product(_1st, _2nd, _3rd):
print(element)

关于python - 混合 3 个列表,每个列表 35 个元素 Python3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com