Last active
January 16, 2018 03:15
-
-
Save SamyBencherif/91c69521cdf9900122546727544c749e to your computer and use it in GitHub Desktop.
Better Binary Output Python (from a trashy one-liner)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bbin = lambda x: ''.join([' '+x if i%4==0 and i!=0 else x for i,x in enumerate(bin(x)[2:].zfill((len(bin(x))-2-1)/4*4+4))]) | |
print(bbin(8039)) #0001 1111 0110 0111 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment