On Tue, 03 Sep 2019 17:27:59 +1000, Cameron Simpson wrote:
> It was merely that it is hardwired in your code (and you need to wire in
> something). Just keep in mind that _if_ this script runs in a non-utf8
> environment the decoding may be wrong. Unlikely to actually happen
> though.
Thanks, fix
On 03Sep2019 03:59, Hongyi Zhao wrote:
On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote:
Finally, the .decode('utf8') assumes your locale is UTF8 based. It
probably is, but if it isn't then you may get mojibake.
Nowadays, most of the os use utf8 as the default locale. Am I wrong?
On Tue, 03 Sep 2019 08:24:17 +1000, Cameron Simpson wrote:
> It seems reasonable to me, but I would not use stderr=subprocess.STDOUT.
> Why did you do that? The stderr stream pretty much exists to avoid
> polluting stdout with error messages.
Thanks for your suggestion.
>
> For really complex s
On 02Sep2019 13:20, Hongyi Zhao wrote:
I try to execute some complex shell commands with in python and obtain
the output, I tried the following method:
For python 3.x:
import subprocess
cmd= some_complex_command_with_pipe_and_others
ps = subprocess.Popen
(cmd,shell=True,stdout=subprocess.PIPE,