printing json value to file
Question: 
       #!/usr/bin/python
    
    
    import os
    
    import json
    
    import urllib
    import urllib2
    
    url = "https://www.example.com"
    parameters = {'resource': 'aaaa',
            'apikey': '1111'}
    data = urllib.urlencode(parameters)
    req = urllib2.Request(url, data)
    response = urllib2.urlopen(req)
    json_data = response.read()
    
    with open("test.json") as json_file:
        json_file.write(json_data)
    
    print json_data
    

I dont see I use json again it was before json_data was used now.


Answer: As Martijn Pieters pointed out, the data is already encoded so you shouldn't
need the `json` module at all in this case

You can just write the output to a file

    
    
    json_data = response.read()
    
    with open("test.json" , "w") as json_file:
        json_file.write(json_data)
    

