How do I display unicode value stored in a string variable using ord()

Ian Kelly ian.g.kelly at gmail.com
Sun Aug 19 14:31:09 EDT 2012


On Sun, Aug 19, 2012 at 12:20 PM, Paul Rubin <no.email at nospam.invalid> wrote:
> Ian Kelly <ian.g.kelly at gmail.com> writes:
>>>>> sys.getsizeof(bytes(range(256)).decode('latin1'))
>> 329
>
> Please try:
>
>    print (type(bytes(range(256)).decode('latin1')))
>
> to make sure that what comes back is actually a unicode string rather
> than a byte string.

As I understand it, the decode method never returns a byte string in
Python 3, but if you insist:

>>> print (type(bytes(range(256)).decode('latin1')))
<class 'str'>



More information about the Python-list mailing list