有没有办法使用列表中的字符串作为数组的标签?

Is there a way to use a string from a list as the label for an array?

我有以这种格式的列表形式提供给我的数据:

['NAME', 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0]

我想做的是将其转换为具有以下格式的数组:

NAME=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0]

有没有办法用代码做到这一点,还是我最好手动标记一些数组并向它们附加数据?

你可以使用字典:

# suppose that l is your list

my_data = {l[0]: l[1:]}

稍后在代码中,您可以使用:

my_data['NAME']