gpt4 book ai didi

python - 如何拆分列表中的字符串列表?

转载 作者:行者123 更新时间:2023-11-28 20:57:11 24 4
gpt4 key购买 nike

让我们来看看:

my_list=[["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"]]

我正在寻找的结果:

0. a    _ b    (c)
1. d _ e (f)
2. g _ h (j)
3. j _ k (l)

最佳答案

要在控制台中准确打印输出,请迭代外部列表并使用 enumeratestr.format:

values = [["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"]]

for i, x in enumerate(values):
print("{}. {} _ {} ({})".format(i, *x))
# 0. a _ b (c)
# 1. d _ e (f)
# 2. g _ h (i)
# 3. j _ k (l)

关于python - 如何拆分列表中的字符串列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53635654/

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