📅  最后修改于: 2022-03-11 14:46:37.549000             🧑  作者: Mango
nums = [1, 2, 1, 1, 4, -4, 2, 2, 4, 2, 5, 7]
dict_in_dict = defaultdict(dict)
for i in range(0, len(nums), 3):
dict_in_dict[nums[i+1]][nums[i]] = -1*nums[i+2]
dict(dict_in_dict)
# result
# {2: {1: -1, 2: -4}, 4: {1: 4}, 5: {2: -7}}