我有一个字典{'Key': 'Name', 'Value': 'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'}
并且我希望输出为CCD_ 2。
这可以通过检索Key
和Value
的值轻松完成。
x = {'Key': 'Name', 'Value': 'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'}
newDict = {x['Key']:x['Value']}
#or newDict = {x.get('Key'):x.get('Value')} is None may occur
输出
{'Name': 'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'}
没什么可做的。只需编写这个字典,然后检索它。您需要的值就会到来。
dict1={'Name':'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'}
print(
dict1
)
# Here your key is 'Name' and the value is 'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'
输出:{'Name': 'VOL-18fd3f81-b69e-47a8-8759-3e04abac962d'}