Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6563357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:49:18+00:00 2026-05-25T13:49:18+00:00

I’m trying to send urlencode() data to my web server. The data used for

  • 0

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:

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

I’m doing the following:

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)

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.

This is the content of the input text file:

{'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'}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:49:19+00:00Added an answer on May 25, 2026 at 1:49 pm

    I’ll go ahead and post my comment as an answer, as it is the answer. You’re calling dict() on a string. The dict() function expects one of two types of input. Either A. a list of tuples that form (key, value) pairs, or B. keyword arguments that come in the form key = value. You’re not passing either of those.

    — Extra detail for the Comments —

    >>> input = {'key1': 'value1', 'key2': 'value2'}
    >>> type(input)
    <type 'dict'>
    >>> dict(input)
    {'key2': 'value2', 'key1': 'value1'}
    >>> input = "{'key1': 'value1', 'key2': 'value2'}" # This is your 2nd form.
    >>> type(input)
    <type 'str'>
    >>> dict(input)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: dictionary update sequence element #0 has length 1; 2 is required
    

    Also, for what it’s worth, in your first example the call to dict() is superfluous. You already have a dictionary which was declared using literal syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.