我有一个pickle文件,其中存储了以下数据:
indices = np.load("descritores/indices_pessoa.pickle")
print(indices) # result
{0: 'fotos\\pessoa.1.1.jpg', 1: 'fotos\\pessoa.1.2.jpg', 2: 'fotos\\pessoa.1.3.jpg', 3: 'fotos\\pessoa.2.1.jpg', 4: 'fotos\\pessoa.2.2.jpg', 5: 'fotos\\pessoa.2.3.jpg'}
我想获取包含“pessoa.1”作为子字符串的元素的所有索引,并将它们从列表中删除。你知道吗
我已经试过了,但没有成功:
r = [i for i in indices if "pessoa.1" in i]
print(r)
作为你问题的输出,我看了词典。你知道吗
如果您将“index”理解为字典中的一个键,只需迭代它。你知道吗
相关问题 更多 >
编程相关推荐