I'm using os.popen() method to run commands on cmd and get response with .read(). When I'm encountering an ERROR, the read returns '' and the output just printed. For Example -
exit_code = popen("taskkill /IM chrome.exe /F").read()
print(exit_code)
# When Chrome closed
>>> ERROR: The process "chrome.exe" not found.
>>> ''
How can I get this ERROR in my exit_code variable?