Using Python 3.4, I am trying to convert a string to padded ASCII values (for each character).
Given a sting:
myString = "hello world"
Convert each character to ASCII and join back into a single string:
asciiString = ''.join(str(ord(c)) for c in myString)
This works great, returning:
'10410110810811132119111114108100'
I would like to pad EACH CHARACTER to 7 digits and then join. I've been trying to do this with format
and have tried so many combinations of join
, format
, str
, and ord
that I can't even list them all. Can someone please help me figure out how to add format to the "asciiString =" line? Maybe this can't be done in a single line of code?