If you want to have multiple values โโfor a dictionary that the standard python dictionary does not offer, than you can use
werkzeug.datastructures.MultiDict os.environ = MultiDict([('Key1', 'First Value'), ('Key1', 'Second Value')])
The update will also work the same as I mentioned below.
If you do not want to keep the old key values โโbefore merging with the new dictionary, you can do the following.
Since os.environ is a dictionary that you already have in memory, another dict - the one you are reading should be converted to json. I usually use ujson since it is really fast.
os.environ.update(new_dict)
If you want to save json u, you can send it to a file.
import ujson with open('data.json', 'w') as file: ujson.dump(dict(**os.environ), file)
if you want to read the file and update the os.environ dictionary that you can use.
with open('environ.json', 'r') as f: os.environ.update(ujson.load(f))
Angelo
source share