gpt4 book ai didi

python - 在 Python 中创建四个列表的所有可能组合的最有效方法?

转载 作者:太空狗 更新时间:2023-10-30 00:24:41 25 4
gpt4 key购买 nike

我有四个不同的列表。 headersdescriptionsshort_descriptionsmisc。我想将这些组合成所有可能的打印方式:

header\n
description\n
short_description\n
misc

就像我有(出于显而易见的原因,我在这个例子中跳过了 short_description 和 misc)

headers = ['Hello there', 'Hi there!']
description = ['I like pie', 'Ho ho ho']
...

我希望它打印出来:

Hello there
I like pie
...

Hello there
Ho ho ho
...

Hi there!
I like pie
...

Hi there!
Ho ho ho
...

您认为最好/最干净/最有效的方法是什么? for - 嵌套是唯一的出路吗?

最佳答案

关于python - 在 Python 中创建四个列表的所有可能组合的最有效方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2390316/

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