Linked Questions
52 questions linked to/from Convert binary to ASCII and vice versa
8
votes
3
answers
36k
views
How to convert binary string to ascii string in python? [duplicate]
I've made a little python program that reads binary from a file and stores it to a text file, read the text file and store the binary. But, I can't get the binary to work...
it reads the files like ...
3
votes
1
answer
10k
views
Python Binary string to ASCII text [duplicate]
x = "01100001"
How do i convert this string into ASCII
Expected Result:
print(x.somefunction())
Output: a
3
votes
4
answers
5k
views
Convert numpy binary string array back to string [duplicate]
I have a numpy binary array like this:
np_bin_array = [0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
It was 8-bit ...
-4
votes
2
answers
297
views
interpret a string made of 0 and 1 as a binary sequence? [duplicate]
Using python, I want to convert/interpret a string made of 0 and 1 as if it was binary.
Assume I have a string that looks like this:
>>>str = "...
0
votes
0
answers
454
views
'utf-8' codec can't decode byte 0xa6 in position 1: invalid start byte [duplicate]
i was trying to make ascii from binary. but i got error
'utf-8' codec can't decode byte 0xa6 in position 1: invalid start byte
here's my code, please help me
def stringmodulasi(f):
f = "...
0
votes
2
answers
113
views
Convert binary back to ascii in python [duplicate]
So i have a function that converts an alphabet character to it's binary.
def toBinary(char):
return "".join([format(ord(char), '#010b')[2:]])
For example, toBinary('a') gives me
01100001
How do ...
0
votes
0
answers
46
views
Issue while trying to convert ascii characters to a binary value [duplicate]
So firstly I have two lists :
l1 = [chr(x) for x in range(32,160)]
l2 = [bin(x)[2:].rjust(7,'0') for x in range(128)]
The first one list 128 characters, and the second 128 binary values (7 bits so ...
184
votes
10
answers
655k
views
How to convert string to binary?
I am in need of a way to get the binary representation of a string in python. e.g.
st = "hello world"
toBinary(st)
Is there a module of some neat way of doing this?
26
votes
11
answers
94k
views
Convert string to list of bits and viceversa
I need to convert an ASCII string into a list of bits and vice versa:
str = "Hi" -> [0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1]
[0,1,0,0,1,0,0,0,0,1,1,0,1,0,0,1] -> "Hi"
Dan's user avatar
- 1,546
18
votes
3
answers
87k
views
Convert binary string to bytearray in Python 3
Despite the many related questions, I can't find any that match my problem. I'd like to change a binary string (for example, "0110100001101001") into a byte array (same example, b"hi").
I tried this:...
12
votes
7
answers
41k
views
Converting from hex to binary without losing leading 0's python
I have a hex value in a string like
h = '00112233aabbccddee'
I know I can convert this to binary with:
h = bin(int(h, 16))[2:]
However, this loses the leading 0's. Is there anyway to do this ...
19
votes
6
answers
116k
views
Binary to String/Text in Python
I have searched many times online and I have not been able to find a way to convert my binary string variable, X
X = "1000100100010110001101000001101010110011001010100"
into a UTF-8 string value.
I ...
10
votes
5
answers
17k
views
Convert Python str/unicode object to binary/hex blob
Is there an easy way to get some str/unicode object represented as a big binary number (or an hex one)?
I've been reading some answers to related questions but none of them works for my scenario.
I ...
10
votes
2
answers
55k
views
Python how to read raw binary from a file? (audio/video/text)
I want to read the raw binary of a file and put it into a string. Currently I am opening a file with the "rb" flag and printing the byte but it's coming up as ASCII characters (for text that is, for ...
8
votes
3
answers
29k
views
Converting bits to bytes in Python
I am trying to convert a bit string into a byte string, in Python 3.x. In each byte, bits are filled from high order to low order. The last byte is filled with zeros if necessary. The bit string is ...
user avatar
user1220978