10 examples of 'python binary to string' in Python

Every line of 'python binary to string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
9def to_binary(x): return '' if x == 0 else to_binary(int(x / 256)) + chr(x % 256)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

549@staticmethod
550def binary_to_string(s):
551 return s.decode('ascii')
5def _get_binary_string(value):
6 a = bin(value)[2:]
7 while len(a) < 8:
8 a = '0' + a
9 return a
53def to_binary(n, result=""):
54 if n < 2:
55 return str(n) + result
56 return to_binary(n/2, str(n%2) + result)
18def hex_to_binary(hex_string):
19 return ''.join([b.decode('hex') for b in hex_string.split(" ")])
79def as_binary(self):
80 output = ''
81 for n in bytes(self):
82 output += ''.join(str(1 & (int(n) >> i)) for i in range(8)[::-1])
83 return output
124def _ip_to_binary_string(ip):
125 integer = struct.unpack('!L', socket.inet_aton(ip))[0]
126 binary = bin(integer)[2:].zfill(32)
127 return binary
74def toBinary(number, zfill = 7):
75 return list(str(bin(number))[2:].zfill(zfill))
42def intlist_to_binary(intlist):
43 '''Convert a list of integers to a binary string type'''
44 return bytes(intlist)
399def __binary_as_string(self, register_value):
400 return bin(register_value)[2:].zfill(16)

Related snippets