chr(i) ASCII under Python 3

Antoine Pitrou solipsis at pitrou.net
Tue Apr 27 10:04:01 CEST 2010


Le Mon, 26 Apr 2010 22:26:28 +0200, Alf P. Steinbach a écrit :
> On 26.04.2010 22:12, * Dodo:
>> Hi all,
>> Under python 2.6, chr() "Return a string of one character whose ASCII
>> code is the integer i." (quoted from docs.python.org) Under python 3.1,
>> chr() "Return the string of one character whose Unicode codepoint is
>> the integer i."
>>
>> I want to convert a ASCII code back to a character under python 3, not
>> Unicode.
>>
>> How can I do that?
> 
> Just use chr().

Or, if you want a bytes object, just use the bytes constructor:

>>> bytes([65])
b'A'

Regards

Antoine.




More information about the Python-list mailing list