decimal to string conv

Discussion in 'Python' started by Aj, Feb 27, 2009.

  1. Aj

    Aj Guest

    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.
     
    Aj, Feb 27, 2009
    #1
    1. Advertising

  2. Aj

    Chris Rebert Guest

    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
     
    Chris Rebert, Feb 27, 2009
    #2
    1. Advertising

  3. Aj

    Aj Guest

    On Feb 27, 10:58 am, Chris Rebert <> wrote:
    > 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


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

    cheers
    Aj
     
    Aj, Feb 27, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Epler
    Replies:
    2
    Views:
    283
    Avraham Makeler
    Apr 21, 2004
  2. A.Dagostino

    Date Conv

    A.Dagostino, Jan 11, 2006, in forum: ASP General
    Replies:
    1
    Views:
    121
    Bob Barrows [MVP]
    Jan 11, 2006
  3. mike

    date conv

    mike, Jul 28, 2005, in forum: Javascript
    Replies:
    4
    Views:
    133
    Dr John Stockton
    Jul 29, 2005
Loading...

Share This Page