Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

char to binary python

>>> st = "hello world"
>>> ' '.join(format(ord(x), 'b') for x in st)
'1101000 1100101 1101100 1101100 1101111 100000 1110111 1101111 1110010 1101100 1100100'

#using `bytearray`
>>> ' '.join(format(x, 'b') for x in bytearray(st, 'utf-8'))
'1101000 1100101 1101100 1101100 1101111 100000 1110111 1101111 1110010 1101100 1100100'
Comment

PREVIOUS NEXT
Code Example
Python :: pytorch tensor change dimension order 
Python :: python gui capture user input 
Python :: pandas convert to 2 digits decimal 
Python :: python heart code 
Python :: inverse matrix numpy 
Python :: matplotlib title 
Python :: python remove first and last character from string 
Python :: discord.py presence 
Python :: python datetime add minutes 
Python :: random word generator python 
Python :: csv to numpy array 
Python :: string with comma to int python 
Python :: pd.set_option show all rows 
Python :: how to make computer go in sleep mode using pythn 
Python :: copy text python 
Python :: tesseract.exe python 
Python :: python generate table 
Python :: discord.py add reaction to message 
Python :: how to remove all spaces from a string in python 
Python :: conda install nltk 
Python :: 2 - 20 python 
Python :: spark dataframe get unique values 
Python :: how to detect a keypress tkinter 
Python :: log scale seaborn 
Python :: isinstance numpy array 
Python :: import forms 
Python :: how to count stopwords in df 
Python :: pyspark create empty dataframe 
Python :: button images in tkinter 
Python :: how to change font sizetkniter 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =