daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Apr 20th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2.  
  3. data = {
  4.        'var': {'var2': 'var3',
  5.                 'var4': int(1),
  6.                'var7': int(100)}}
  7.  
  8. def updatedata():
  9.     with open('data1.json', 'w', encoding='utf8') as outfile:
  10.         var5 = data['var']['var4']
  11.         var6 = var5 + 11
  12.         data['var']['var4'] = var6
  13.         str_ = json.dumps(data,
  14.                           indent=4, sort_keys=True,
  15.                           separators=(',', ': '), ensure_ascii=False)
  16.         outfile.write(str_)
  17.  
  18. updatedata()
RAW Paste Data
Top