0
response = requests.post(url, json=dict_element, headers=headers, verify=False)


with open("backup_output.txt", "wb") as f:
    for dict_element in json_dict:
        f.write(response.content)
        print(response.content)

    

This is an example of what I DONT!! want to use.

response = requests.post(url, json=dict_element, headers=headers, verify=False)


with open("backup_output.txt", "wb") as f:
    for dict_element in json_dict:
        f.write(response.content)
        print(response.content)


This writes the same output over and over to the same file, doesn't appropriately write a new file per response to my POST. Instead it takes the last post in a series of post request and writes that over and over again, not recording the response of the POST prior to the very last.

  • # create a file with date as a name day-month-year file_name = x.strftime('%d-%m-%Y.txt') with open(file_name, 'w') as fp: print('created', file_name) Using Date and Time Stamp for file creation is the closest capability I have found similar to what I am trying to accomplish. – John Watkins IT Professional Nov 23 '22 at 15:32

0 Answers0