I have a set of string variables in Python code. I want to create a set of dictionaries with names as strings. And I also want to assign values for these dictionary using variable values.
I am wondering how to write code for this?
Please note that, in below code, at line my_func1_dict = xxx
, I also need to fill the func1
with a variable value.
For example:
name = {func1, func2, fun3}
exec("my_%s_dict = %s" % (name[0], {}))
my_func1_dict = xxx