Execute complex shell commands within python and obtain the output.

Cameron Simpson cs at cskk.id.au
Tue Sep 3 03:27:59 EDT 2019


On 03Sep2019 03:59, Hongyi Zhao <hongyi.zhao at gmail.com> 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?

You are not wrong. So it is pretty safe to do what you did.

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.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list