Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

string to bits python

str = "cde"

str_as_byte_array = bytearray(str, "utf8") 
bytes_arr = []

for byte in str_as_byte_array:
	binary_representation = bin(byte)
	bytes_arr.append(binary_representation)

print(bytes_arr)  # ['0b1100011', '0b1100100', '0b1100101']
Comment

PREVIOUS NEXT
Code Example
Python :: progressbar time in python 
Python :: find all color in image python 
Python :: pymupdf extract all text from pdf 
Python :: count elements in list 
Python :: TypeError: expected string or bytes-like object site:stackoverflow.com 
Python :: odd or even in python 
Python :: telebot send file 
Python :: remove substring from string python 
Python :: python find smallest value in 2d list 
Python :: np.percentile 
Python :: numpy delete column 
Python :: rotate image python 
Python :: django view 
Python :: cut rows dataframe 
Python :: unique_together what is used of it in django 
Python :: pandas append csv file 
Python :: Write a Python program to count the number of lines in a text file. 
Python :: pyton filter 
Python :: discord py fetch channel by id 
Python :: python exam questions pdf 
Python :: python run exe 
Python :: how to use h5 file in python 
Python :: levenshtein distance 
Python :: python datetime format string 
Python :: python 3 custom sort with compare 
Python :: python one line if statement no else 
Python :: count different values in list python 
Python :: flatten image python numpy 
Python :: pathlib remove extension 
Python :: how to run python module every 10 sec 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =