[SciPy-User] Inverse of binary_repr
Warren Weckesser
warren.weckesser at enthought.com
Tue Mar 27 10:06:07 EDT 2012
On Tue, Mar 27, 2012 at 9:03 AM, Alexander Borghgraef <
alexander.borghgraef.rma at gmail.com> wrote:
> Hi all,
>
> Is there an inverse function of binary_repr, which takes a binary string
> representation of a number ( like '100') and returns an integer?
>
>
Use the optional second argument of int(), which is the base:
In [1]: s = "1001"
In [2]: int(s, 2)
Out[2]: 9
Warren
> --
> Alex Borghgraef
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120327/c384ebfa/attachment.html>
More information about the SciPy-User
mailing list