Give a one line expression to convert a number to its binary
representation in Python. For example, 258 to "100000010".
Friday, September 12, 2008
Subscribe to:
Post Comments (Atom)
Programming tricks related to ActionScript, Python, C/C++ and Java. See the comments for answers.
1 comment:
If number is in data, then the following expression converts.
''.join([''.join([('1' if (ord(x) & (1<<(7-y))) else '0') for y in range(0, 8)]) for x in data])
Post a Comment