reading info from text file and passing read lines to urlencode python function
<p>I'm trying to send urlencode() data to my web server.
The data used for the urlencode() function is read from a text file located on my local machine.
When I read the input data for the urlencode() function from the .py script no error is being thrown.
However, if the input data for the urlencode() function is comming from a local input text file I get the following error:</p>

<p>Traceback (most recent call last):
  File "active_directory_ssl_test.py", line 30, in 
    params = urllib.urlencode(dict(LINE))
ValueError: dictionary update sequence element #0 has length 1; 2 is required</p>

<p>I'm doing the following:</p>

<pre><code>FILE=open(IN_FILE, 'r')
LINE = FILE.readline()
while LINE:
    print LINE
    LINE = FILE.readline()
    params = urllib.urlencode(dict(LINE))
    try:
        f_handler = urlopen('https://host_name/path_name/file_name', params)
</code></pre>

<p>Why is there a difference, an error, when reading data from a text file. In both cases a variable is used as a parameter to the urlencode() function.</p>

<p>This is the content of the input text file:</p>

<pre><code>{'hostname' : 'host.1.com', 'port' : '389', 'basedn' : 'CN=Users,DC=prem,DC=local', 'username' : 'CN=Administrator,CN=Users,DC=onprem,DC=local', 'password' : 'passwd', 'roupname' : 'CN=Group,CN=Users,DC=onprem,DC=local', 'attribute' : 'name', 'enabled' : 'sync', 'impsync' : 'sync', 'enabled' : 'enabled', 'username' : 'user@1.com', 'password' : 'passwd', 'update' ; 'update'}
</code></pre>
