binary literal

Ulrich Eckhardt eckhardt at satorlaser.com
Wed Jul 22 06:25:32 EDT 2009


superpollo wrote:
> i can insert a hex value for a character literal in a string:
> 
>  >>> stuff = "\x45"
>  >>> print stuff
> E
>  >>>
> 
> can i do something like the above, but using a *binary* number? (e.g.
> 00101101 instead of 45) ?

There are binary number literals since 2.6 and there is the chr() function.

 >>> print chr(0b1000101)
E

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list