Assuming you just want to merge two versions of the object and create a new one( I trimmed the versioned_objects response):
In [2]: versioned_objects = s3.list_object_versions('myversionedbucket')
In [4]: versioned_objects
Out[4]:
{'ResponseMetadata': {,,
'Versions': [{',
'Key': 'test.json',
'VersionId': 'Bx1atH2cYGErrIsd_A2ApmMPFdIFo4c0',
'IsLatest': True,
},
{
'Key': 'test.json',
'VersionId': 'BNE6HyQ38lWhb.iLIMt6sMJE1RcaG1j2',
'IsLatest': False,
},
{,
'Key': 'test.json',
'VersionId': 'bYu_OzyXdRLLtYLaHqgnf.srvKpZmI3F',
'Name': 'myversionedbucket',
}
}
In [17]: current_version = json.loads(s3.get_object(Bucket='myversionedbucket', Key='test.json', VersionId='Bx1atH2cYGErrIsd_A2ApmMPFdIFo4c0')['Body'].read())
In [18]: older_version = json.loads(s3.get_object(Bucket='myversionedbucket', Key='test.json', VersionId='BNE6HyQ38lWhb.iLIMt6sMJE1RcaG1j2')['Body'].read())
In [19]: current_version
Out[19]: {'name': 'markus', 'lastname': 'schneider'}
In [20]: older_version
Out[20]: {'name': 'markus'}
In [31]: merged = {**current_version, **older_version}
In [32]: merged
Out[32]: {'name': 'markus', 'lastname': 'schneider'}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…