Python: ValueError: too many values to unpack

I try to write a code with twitter api on GAE,
I got the error with the code. Please help!
the values of k and v are

Status: 500 Internal Server Error
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 773

<pre>Traceback (most recent call last):
  File &quot;C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\;, line 511, in __call__
  File &quot;D:\Workspaces\fmnbots\;, line 82, in get
  File &quot;D:\Workspaces\fmnbots\;, line 188, in make_request
    return self.make_async_request(url, token, secret, additional_params, protected, method).get_result()
  File &quot;D:\Workspaces\fmnbots\;, line 177, in make_async_request
  File &quot;D:\Workspaces\fmnbots\;, line 146, in prepare_request
    [k] = tmp.encode('utf8')
ValueError: too many values to unpack
for k,v in params.items():
        if isinstance(v, unicode):
            print k
            print v
***         [k] = v.encode('utf8')

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If the intention is to convert the unicode string into the serie of bytes, then you may forgot to write the dictionary identifier at the begining of the line 5, like:

          param[k] = v.encode('utf8')

    [k] = something
is probably the same as
    (k) = something
which is more usual for cases like
    (a, b) = something
which is usually written without parentheses
     a, b = something

The meaning is that the 'something' is iterated and the values are assigned to a, and b respectively. In the last case, the something must have exactly two items.

Back to your case, you try to iterate through resulting sequence of bytes, but there is more of them than of the variables at the left of the assignment.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.