title: python: How to write variable-contents to a file?
body: <p>How do I pass the variable-contents to the <code>f.write()</code> function, so that the variable-contents would be written to file? </p>
  
  <blockquote>
    <p>i.e. move variable jsonData to function f.write()</p>
  </blockquote>
  
  <pre><code> def get(self):
          url = 'http://httpbin.org/get'
          r = requests.get(url)
          data = r.text
          jsonData = json.loads(data)  
  
          # #TODO: send jsonData variable to log file.
          f = open('test_logs.txt', 'a+')
          f.write('jsonData') 
          f.close()
  
          return jsonData
  </code></pre>