title: How to write a variable in a json file?
body: <p>I searched for a long time but I am not really familiar with python and json and I can't find the answer of my problem.
  Here is my Python script</p>
  
  <p>import json</p>
  
  <pre><code>jsonFile = open("config.json", "r")
  data = json.load(jsonFile)
  data.format(friendly, teaching, leader, target)
  print(data)
  </code></pre>
  
  <p>Here is json the file:</p>
  
  <pre><code>{
      "commend": {
          "friendly": {},
          "teaching": {},
          "leader": {}
      },
      "account": {
          "username": "",
          "password": "",
          "sharedSecret": ""
      },
      "proxy": {
          "enabled": false,
          "file": "proxies.txt",
          "switchProxyEveryXaccounts": 5
      },
      "type": "COMMEND",
      "method": "SERVER",
      "target": "https://steamcommunity.com/id/{}",
      "perChunk": 20,
      "betweenChunks": 300000,
      "cooldown": 28800000,
      "steamWebAPIKey": "{}",
      "disableUpdateCheck": false
  }
  </code></pre>
  
  <p>I tried <code>.format</code> but we can't use this method with with a dictionary.</p>
  
  <p>With your help I managed to find the answer A big thank you for your speed and your help ! Here is what I did:</p>
  
  <pre><code>import json
  
      jsonFile = open("config.json", "r")
      data = json.load(jsonFile)
      (data['commend']['friendly']) = nbfriendly
      (data['commend']['teaching']) = nbteaching
      (data['commend']['leader']) = nbleader
      print(data)
      print(data)
  </code></pre>