Return to Snippet

Revision: 36277
at November 20, 2010 03:32 by vyahhi


Updated Code
binary_int = lambda i, c = (lambda i, c: i and (c(i >> 1, c) + str(i & 1)) or ''): c(i, c)
binary_str = lambda s: ''.join([binary(ord(ch)) for ch in s])

print binary_str('hello world')

Revision: 36276
at November 20, 2010 03:29 by vyahhi


Initial Code
binary = lambda i, c = (lambda i, c: i and (c(i >> 1, c) + str(i & 1)) or ''): c(i, c)

s = 'hello world'
''.join([binary(ord(ch)) for ch in s])

Initial URL

                                

Initial Description

                                

Initial Title
String to binary

Initial Tags

                                

Initial Language
Python