gpt4 book ai didi

python - 有没有办法在子列表中加入字符串列表

转载 作者:行者123 更新时间:2023-11-28 21:59:56 25 4
gpt4 key购买 nike

我有以下子列表:

[['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]

但是是否可以在子列表中加入列表呢?

[['ab'], ['cd'], ['ef'], ['g']]

最佳答案

>>> L = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
>>> [[''.join(x)] for x in L]
[['ab'], ['cd'], ['ef'], ['g']]

关于python - 有没有办法在子列表中加入字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15788504/

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