decimal to string conv

A

Aj

Hi all,

I am trying to convert a list to string.
example [80, 89,84,72,79,78,0] is my input. I could make it to just
[0x50,0x59,0x54,0x48,0x4F,0x4E,0x00].
but I wanted it to be like "PYTHON".
I couldnt even convert 0x50 to 'P'. Is there any library api available
to do this? it will be really helpful to me.
dont bang me if its already being asked. I just 'dived' into python
yesterday.

cheers
Aj.
 
C

Chris Rebert

Hi all,

I am trying to convert a list to string.
example [80, 89,84,72,79,78,0] is my input. I could make it to just
[0x50,0x59,0x54,0x48,0x4F,0x4E,0x00].
but I wanted it to be like "PYTHON".
I couldnt even convert 0x50 to 'P'. Is there any library api available
to do this? it will be really helpful to me.

lst = [80, 89,84,72,79,78,0]
print ''.join(map(chr, lst[:-1]))

Cheers,
Chris
 
A

Aj

I am trying to convert a list to string.
example [80, 89,84,72,79,78,0] is my input. I could make it to just
[0x50,0x59,0x54,0x48,0x4F,0x4E,0x00].
but I wanted it to be like "PYTHON".
I couldnt even convert 0x50 to 'P'. Is there any library api available
to do this? it will be really helpful to me.

lst = [80, 89,84,72,79,78,0]
print ''.join(map(chr, lst[:-1]))

Cheers,
Chris

wow... that was quick and it works perfect with my inputs.
thanx & have a nice day.

cheers
Aj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top