Text file to list in Python
Question: Suppose I have a document called test1.txt that contains the following
numbers:

    
    
    133213
    123123
    349135
    345345
    

I want to be able to take each number and append it to the end of the URL
below to make a HTTP request. How do I stuff the id's into a list and call
each one? This is what I have so far.

    
    
    file = open('C:\Users\Owner\Desktop\\test1.txt')
    startcount = 1
    endcount = len(file.readlines())
    
    o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
    urllib2.install_opener( o )
    
    while startcount < endcount:
    
        f = o.open( 'http://www.test.com/?userid=' + ID GOES HERE )
        f.close()
    


Answer: 
    >>> from urllib import urlencode
    >>> with open('C:\Users\Owner\Desktop\\test1.txt') as myfile:
    ...     for line in myfile:
    ...             params = urlencode({'userid': line.strip()})
    ...             f = opener.open('http://www.test.com/?' + params)
    ...             # do sth
    ... 
    

