Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python print bytes

#this will print a string as "list of chars", "list of int" and "list of bytes"
x=" abcdefg "
print (f'x as list of chars { list( x )}')
y = [ (ord(item)) for item in list( x )]
print (f'x as decimals      { y }')
z = [ f'{item:x}' for item in y] 
print (f'x as bytes         { z }')

#output
#  x as list of chars [' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', ' ']
#  x as decimals      [32, 97, 98, 99, 100, 101, 102, 103, 32]
#  x as bytes         ['20', '61', '62', '63', '64', '65', '66', '67', '20']
Comment

PREVIOUS NEXT
Code Example
Python :: unique python 
Python :: docker compose cron 
Python :: numpy.where 
Python :: is there a null data type in python 
Python :: operator overloading python 
Python :: loop through files in a directory python 
Python :: get ip address 
Python :: Counter() Function 
Python :: longest common prefix 
Python :: remove whitespace method 
Python :: remove a part of a string python 
Python :: python power of natural number 
Python :: pandas filter columns with IN 
Python :: Removing Elements from Python Dictionary Using popitem() method 
Python :: simple python class 
Python :: download button image streamlit 
Python :: python list operation 
Python :: itertools count 
Python :: private key 
Python :: cache-control no cache django 
Python :: import csv in python 
Python :: print list of list line by line python 
Python :: python test framework 
Python :: python string variable 
Python :: map in python 3 
Python :: argparse one argument or without argument 
Python :: jupiter lab 
Python :: cmap seaborn 
Python :: deque in python 
Python :: pandas drop rows 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =