How to covert ASCII to integer in Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Skonieczny, Chris

    How to covert ASCII to integer in Python?

    YOU SHOULD REMOVE or CORRECT YOUR POST here:


    It is not true - eg. try :
    a='P' # P is ASCII , isn't it ?
    b=int(a)
    and what you will get ? An error !!!

    Or probably you yourself should - quote :
    "You probably should go through the tutorial ASAP that is located here:

    http://docs.python.org/tut/ "


  • David C. Ullrich

    #2
    Re: How to covert ASCII to integer in Python?

    In article <mailman.1763.1 212139351.12834 .python-list@python.org >,
    "Skonieczny , Chris" <Skonieczny.C@e mssatcom.comwro te:
    YOU SHOULD REMOVE or CORRECT YOUR POST here:
    http://mail.python.org/pipermail/pyt...ry/427841.html
    Why? There's nothing wrong there.
    It is not true - eg. try :
    a='P' # P is ASCII , isn't it ?
    b=int(a)
    and what you will get ? An error !!!
    You really don't see any difference between
    "convert '1' to an integer" and "convert 'P' to an integer"?

    In case there's actually a problem you're trying to solve
    here, try ord instead of int.
    Or probably you yourself should - quote :
    "You probably should go through the tutorial ASAP that is located here:
    >
    http://docs.python.org/tut/ "
    >
    ---------------------------------------------------------------------
    [Image]
    --
    David C. Ullrich

    Comment

    • Philipp Pagel

      #3
      Re: How to covert ASCII to integer in Python?

      Skonieczny, Chris <Skonieczny.C@e mssatcom.comwro te:
      YOU SHOULD REMOVE or CORRECT YOUR POST here:

      >
      It is not true - eg. try :
      a='P' # P is ASCII , isn't it ?
      b=int(a)
      and what you will get ? An error !!!
      'P' is obviously not an ASCII representation of a number.
      What did you expect? The closest number by visual appearance?

      cu
      Philipp

      --
      Dr. Philipp Pagel
      Lehrstuhl f. Genomorientiert e Bioinformatik
      Technische Universität München

      Comment

      • Mensanator

        #4
        Re: How to covert ASCII to integer in Python?

        On May 30, 10:03�am, Philipp Pagel <pDOTpa...@helm holtz-muenchen.de>
        wrote:
        Skonieczny, Chris <Skonieczn...@e mssatcom.comwro te:
        YOU SHOULD REMOVE or CORRECT YOUR POST here:
        http://mail.python.org/pipermail/pyt...841.html�
        >
        It is not true - eg. try :
        a='P' � � � � � �# P is ASCII , isn't it ?
        b=int(a)
        and what you will get ? An error !!!
        >
        'P' is obviously not an ASCII representation of a number.
        It is in base 36.
        >>a='P'
        >>b=int(a,36)
        >>b
        25

        What did you expect? The closest number by visual appearance?
        >
        cu
        � � � � Philipp
        >
        --
        Dr. Philipp Pagel
        Lehrstuhl f. Genomorientiert e Bioinformatik
        Technische Universit�t M�nchenhttp://mips.gsf.de/staff/pagel

        Comment

        • Philipp Pagel

          #5
          Re: How to covert ASCII to integer in Python?

          Mensanator <mensanator@aol .comwrote:
          On May 30, 10:03???am, Philipp Pagel <pDOTpa...@helm holtz-muenchen.de>
          wrote:
          'P' is obviously not an ASCII representation of a number.
          It is in base 36.
          Sure, but if that was the OP's intent he would most likely have
          mentioned it...

          As others have already guessed, it's most likely somethink like ord() he
          was after.

          cu
          Philipp

          --
          Dr. Philipp Pagel
          Lehrstuhl f. Genomorientiert e Bioinformatik
          Technische Universität München

          Comment

          Working...