d = {}
d['a'] = {'ra':7, 'dec':8}
d['a']['dist'] = 12
lst=['dst','scr']
length=len(lst)
values=[9,7]
for j in old_i:
if length==1:
d['a'][lst[0]]=values[0]
if length==2:
d[a][lst[0]][lst[1]]=values[1]
由于列表仅包含两项,因此我可以通过硬编码为字典分配值,有没有办法使它能够处理所有长度的泛型?