[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Execute complex shell commands within python and obtain the output.

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 

Cameron Simpson <cs at cskk.id.au>