newbie question

Discussion in 'Python' started by Christoph Lehmann, Sep 4, 2003.

  1. hi
    I need to read in a textfile, where in each line are two strings:

    e.g

    aa 1
    bb 0
    cc 1
    aa 0
    dd 0


    how can I read in each line and put the first string into one variable,
    the second into another variable

    with just one string per line, I did:

    f = open(myfile, 'r')
    for filename in f.readlines():
    mylist.append(string.rstrip(filename)) #remove \n
    or \r\n
    f.close()

    many thanks
    --
    Christoph Lehmann <>
    Christoph Lehmann, Sep 4, 2003
    #1
    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. Jerry C.
    Replies:
    8
    Views:
    214
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    131
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    113
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    102
  5. Miki Tebeka
    Replies:
    0
    Views:
    76
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page