0

I use the following code:

import subprocess
from subprocess import Popen 
log_py = open("/tmp/input.json", 'w')
log = open("/tmp/_log_.txt", 'w')
command = ['python3', './test.py', '-a', '-j']
p = Popen(command, stdout=log_py, stderr=log, shell=False)
p.communicate()

In order to upload the main output of the script to a json file, I use stdout=log_py

But in order not to write any garbage to the json file, I use stderr=log and write them to a separate text file.

Could you please tell me how to ignore the output of stderr= ? That is, do not output anything anywhere, either to the terminal or to a file. Thanks.

Alex Rebell
  • 385
  • 1
  • 11

0 Answers0