gpt4 book ai didi

python - 提取列表的每个列表

转载 作者:行者123 更新时间:2023-11-28 19:49:29 25 4
gpt4 key购买 nike

我有以下列表:

list_sample = [[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0.021, 0.021, 0.021, 0.021, 0.021, 0.021, 0.021], [0.022, 0.022, 0.022, 0.022, 0.022, 0.022, 0.022],...]

我想提取每个列表并将其归因于另一个列表,例如:

for i,line in enumerate(list_sample):
if i==0:
Z_level=line
if i==1:
XD1=line
if i==2:
XD2=line
.....

有没有办法让它更有效?谢谢

最佳答案

或者(补充 RobEarl)回答,

Z_level, XD1, XD2, ... = list_sample

但是,如果您不知道 list_sample 有多大,则需要了解如何在 python 中动态设置变量。你可以检查其中的一些 here

关于python - 提取列表的每个列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19097791/

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