Quantcast
Channel: Convert int to binary string in Python - Stack Overflow
Viewing all articles
Browse latest Browse all 74

Answer by Tom Hale for Python int to binary string?

$
0
0

I feel Martijn Pieter's comment deserves to be highlighted as an answer:

binary_string = format(value, '0{}b'.format(width))

To me is is both clear and versatile.


Viewing all articles
Browse latest Browse all 74

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>