Formatted Input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Deep

    #1

    Formatted Input

    Hi all,
    I am a newbie to python
    I have an input of form
    <one numberspace <another number>
    ie.
    4 3
    how can i assign this to my variables??

  • Frank

    #2
    Re: Formatted Input

    On Mar 10, 11:28 am, "Deep" <deepblue...@gm ail.comwrote:
    Hi all,
    I am a newbie to python
    I have an input of form
    <one numberspace <another number>
    ie.
    4 3
    how can i assign this to my variables??
    Hi,

    you could use:

    aux = f.readline() # read a line from your input file
    new_aux = string.split(au x, ' ') # you can use also other separaters,
    e.g., \t, or ' more than one space', or...
    L = len(new_aux) # number of values
    Remark:
    the elements in new_aux are string, that means you have to convert
    them to numbers by,, e.g., int(row[i]).

    Hope this helps,

    Frank


    Comment

    Working...