как можно строку перевести в единицы и нули ?
PS
python ниже 3
In [1]: import random
In [2]: a = 'this is a test'
In [3]: b = [random.choice((0,1,)) for c in a]
In [4]: b
Out[4]: [0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0]
def b1(n):
return "01"[n%2]
def b2(n):
return b1(n>>1)+b1(n)
def b3(n):
return b2(n>>2)+b2(n)
def b4(n):
return b3(n>>4)+b3(n)
bytes = [ b4(n) for n in range(256)]
def binstring(s):
return ''.join(bytes[ord(c)] for c in s)