Let's say I have a nested dictionary like this:
example_dict = {
'key_one': '{replace_this}',
'key_two': '{also_replace_this} lorem ipsum dolor',
'key_three': {
'nested_key_one': '{and_this}',
'nested_key_two': '{replace_this}',
},
}
What is the best way to format the placeholder string values and either return a new a dictionary or edit the existing example_dict? Also, account for any depth.
UPDATE
I tried out something else.
import json
output = json.dumps(example_dict)
output = output.format(replace_this='hello')
Although I get a KeyError on the first key it encounters from the .format() statement.
{and}. Or is there a set of very specific strings that you want to replace?