gpt4 book ai didi

python - 在Python中将列表列表转换为int的平面列表

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

嗨,我有一个列表,其中每个元素都是一个元素列表:/image/JSH9j.png

[['2199822281'], ['2199822390'], ['2199822392'], ['2199822369'], ['2199822370'], ['2199822284'], ['2199822281']]

我想要的是将其转换为 python 中的整数列表,我该怎么做?

期望输出

[2199822281, 2199822390 ...,2199822281]

请引用图片

最佳答案

这应该可以解决问题:

x = [int(i[0]) for i in list]

其中 list 是上面列表列表的名称,x 是您的输出列表。

关于python - 在Python中将列表列表转换为int的平面列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37872036/

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