Python 从字典中提取数据

Python 从字典中提取数据,python,Python,我想从我的字典中提取数据。我编写了以下代码 subarray = { 'Chr1': data[data[:,0] == 'chr1'], 'Chr2': data[data[:,0] == 'chr2'] } for the_key, the_value in subarray.iteritems(): cnt = len(subarray) for i in range(cnt): lst = the_value[i] chr_name

我想从我的字典中提取数据。我编写了以下代码

subarray = {
   'Chr1': data[data[:,0] == 'chr1'],
   'Chr2': data[data[:,0] == 'chr2']
}
for the_key, the_value in subarray.iteritems():
   cnt = len(subarray)
   for i in range(cnt): 
       lst = the_value[i]
       chr_name = lst[0]
       first_cord = lst[1]
       second_cord = lst[2]
我无法从字典中的列表中提取全部数据,但只能得到23个数据点。我也得到以下错误

IndexError: index 19 is out of bounds for axis 0 with size 19

您获取字典的长度,但索引到值列表中。您可能是指
cnt=len(值)
。由于您不需要
i
,因此只需将lst的
设置为\u值:
。如果需要索引,请使用
enumerate()
。还有:什么是
数据
,为什么要根据比较结果对其进行索引?它是tuple@minitoto不,只是字典里的括号。结尾没有
。但是你需要滚动查看。嗨,实际上数据是我读取文件的数据数组