I execute the following code in both windows cmd and ubuntu bash:
python -c "import xxx"
Error messages output. And when I run:
echo $? / echo %errorlevel%
The value is 1.
When I do the same task in python script with subprocess as follows:
cmdlst = ['python', '-c', '“import xxx”‘]
proc = subprocess.Popen(cmdlst)
retcode = proc.wait()
The retcode is 0. What is the problem and how can I get the correct return code of the command run within a subprocess.
Thanks in advance.
'“import xxx”‘is a very different thing from'"import xxx"', and the former -- which is what is included in the question -- wouldn't exit with status 0).