gpt4 book ai didi

python - 删除空括号并获取值

转载 作者:行者123 更新时间:2023-12-01 07:36:38 25 4
gpt4 key购买 nike

我在下面有这个......我不确定它是列表列表还是只是列表等。

[['346565.09644975792617' '6039234.5627173967659' '102.90000149316718137'
'346519.28163281054003' '6039317.3740590326488' '101.89338011475197732'
'346515.16140150092542' '6039237.1104527609423' '102.81999966426546678']
['346565.09644975792617' '6039234.5627173967659' '102.90000149316718137'
'346515.16140150092542' '6039237.1104527609423' '102.81999966426546678'
'346537.27037519804435' '6039179.8096304181963' '102.07013642431296319']]
[]
[['346714.73278179299086' '6039224.1555810244754' '103.08000181452024435'
'346664.85009351186454' '6039227.5649940613657' '103.06999966149143688'
'346686.75602762267226' '6039181.4495896659791' '102.44271274879886846']
['346664.85009351186454' '6039227.5649940613657' '103.06999966149143688'
'346714.73278179299086' '6039224.1555810244754' '103.08000181452024435'
'346742.24909936846234' '6039268.2906331047416' '102.59342433410905926']]

我想访问所有值,我想如果删除空括号就可以做到这一点,但我无法删除它

我尝试过展平,但是还有其他一些事情,但是当它遇到空的 [] 时,它会出现索引超出范围

[i for i in (array[temp[0]).flat]

我想单独迭代并访问列表中的每个值即

346565.09644975792617
6039234.5627173967659
102.90000149316718137

最佳答案

list2 = [x for x in list1 if x != []]

然后

for i in range(1, len(list2)):
// do what you want with element 'i'

关于python - 删除空括号并获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56962508/

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