Binary numbers

Kent Johnson kent37 at tds.net
Tue Jun 7 20:56:39 EDT 2005


Douglas Soares de Andrade wrote:
> Hi !
> 
> How to work with binary numbers in python ? Is there a way to print a number 
> in its binary form like we do with oct() or hex() ?

This is a popular topic in the Python Cookbook, maybe one of these recipes will suit you:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/219300
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65212

Kent



More information about the Python-list mailing list