Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > decimal to string conv

Reply
Thread Tools

decimal to string conv

 
 
Aj
Guest
Posts: n/a
 
      02-27-2009
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.
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      02-27-2009
On Fri, Feb 27, 2009 at 1:45 AM, Aj <> wrote:
> 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

--
Follow the path of the Iguana...
http://rebertia.com
 
Reply With Quote
 
 
 
 
Aj
Guest
Posts: n/a
 
      02-27-2009
On Feb 27, 10:58*am, Chris Rebert <c...@rebertia.com> wrote:
> On Fri, Feb 27, 2009 at 1:45 AM, Aj <aru...@gmail.com> wrote:
> > 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
>
> --
> Follow the path of the Iguana...http://rebertia.com


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

cheers
Aj
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Layout & Memory Optimizations for Large Docs Conv. to PDF, XPS sherazam Java 0 10-31-2011 10:28 AM
Read Pivot Tables, Shapes in XLSX Files & Stable Excel to PDF Conv. sherazam Java 0 03-10-2011 08:48 AM
Date Conv A.Dagostino ASP General 1 01-11-2006 11:28 AM
from newbie: how specify # of times to invoke a regex; conv tuple to string Jeff Epler Python 2 04-21-2004 10:37 PM
2.4x Tele-conv. on A80? DHB Digital Photography 1 11-11-2003 08:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57