import argparse
import tempfile
import os
import json
storage_path = os.path.join(tempfile.gettempdir(), 'storage.data')
parse = argparse.ArgumentParser()
parse.add_argument('-k', '--key', default=None, required=True)
parse.add_argument('-v', '--val', default=None, required=False)
key = parse.parse_args()
value = parse.parse_args()
dict_cop = {key.key : value.val}
with open(storage_path, 'r') as f:
dictionary = json.load(f)
with open(storage_path, 'w') as f:
dictionary.update(dict_cop)
json.dump(dictionary, f)
with open(storage_path, 'r') as f:
print(json.load(f))
import argparse
import tempfile
import os
parse = argparse.ArgumentParser()
parse.add_argument('-k', '--key', default=None, required=True)
parse.add_argument('-v', '--val', default=None, required=False)
key = parse.parse_args()
value = parse.parse_args()
dict_cop = {key.key : value.val}
dictionary = dict()
dictionary.update(dict_cop)
print(key.key)
print(value.val)
print(dictionary)