Python under PowerShell adds characters
jussi.piitulainen at helsinki.fi
Wed Mar 29 12:39:19 EDT 2017
lyngwyst at gmail.com writes:
> I wrote a Python script, which executed as intended on Linux and from
> cmd.exe on Windows. Then, I ran it from the PowerShell command line,
> all print statements added ^@ after every character.
> Have you seen this? Do you know how to prevent this?
Script is printing UTF-16 or something, viewer is expecting ASCII or
some eight bit code and making null bytes visible as ^@.
Python gets some default encoding from its environment. There are ways
to set the default, and ways to override the default in the script. For
example, you can specify an encoding when you open a file.
More information about the Python-list