Input_data=[{'filename':'file_A','start_page':1,'end_page':3,'angle':90},{'filename':'file_A','start_page':6,'end_page':8,'angle':270},{'filename':'file_B','start_page':2,'end_page':3,'angle':90},{'filename':'file_B','start_page':5,'end_page':5,'angle':270}]
output=[{'filename':'file_A','page':1,'angle':90},
{'filename':'file_A','page':2,'angle':90},{'filename':'file_A','page':3,'angle':90},{'filename':'file_A','page':6,'angle':270},{'filename':'file_A','page':7,'angle':270},
{"文件名":"file_A","页面":8,"角":270 },{' 文件名":"file_B"、"页面":2,"角":90},{"文件名":"file_B","页面":3,"角":90 },{' 文件名":"file_B"、"页面":5,"角":270}]
}
如果我理解正确的话,您应该这样做:
output = []
for d in Input_data:
for i in range(d["start_page"], d["end_page"] + 1):
output.append({'filename':d["filename"], 'page':i, 'angle':d["angle"]})
print(output)