Beginner python 3 unicode question

Chris Angelico rosuav at gmail.com
Sat Nov 16 17:47:11 EST 2013


On Sun, Nov 17, 2013 at 8:19 AM, Laszlo Nagy <gandalf at shopzeus.com> wrote:
>         print("digest",digest,type(digest))
>
> This function was called inside a script, and gave me this:
>
> ('digest', '\xa0\x98\x8b\xff\x04\xf9V;\xbd\x1eIHzh\x10-\xc5!\x14\x1b', <type
> 'str'>)
>

This looks very much like you're running under Python 2. Take care of
which interpreter you're running; that might be because of your
shebang (as Luuk mentioned), or because of what you're typing to
invoke the script; either way, it makes a huge difference. The easiest
solution is probably to invoke the interpreter explicitly:

Interactive mode:
$ python3
Script mode:
$ python3 scriptname.py

But you seem to have something WAY more complex than a single script.
What's the setup? How is Python getting invoked? If your code is
getting imported by something else, no shebang will help you - you
need the other code to be being executed by the other interpreter.

ChrisA



More information about the Python-list mailing list