I have an array with dict
tag_list = [{'Key': 'backup', 'Value': 'true'},
{'Key': 'backup_daily', 'Value': '7'}]
I'd like to convert it to variables, such as:
tag_backup = 'true'
tag_backup_daily = '7'
Any easy way to do that?
If no need to convert it to variables, any other better way to reference these key/value directly?
The best I want to do is to reference as below ways.
tag_list['backup'] = "true"
tag_list['backup_daily'] = "7"
UPDATE #1
Thanks to @Lev Zakharov 's answer, I did with below ways.
>>> new_list = {x['Key']: x['Value'] for x in tag_list}
>>> new_list['backup']
'true'
>>> new_list['backup_daily']
'7'