dictionary - Updating Dictionaries in Python -


i trying have dictionary continuously update long loop running, x , y values changing needed. how tried before getting error message , coming here.

params = urllib.urlencode({'name':'xxxxx', 'pass':'xxxxxxx', 'amount':'x', 'price':'y'}) x = math.floor(first) y = last*1.007-last*.003 params['amount'] = x params['price'] = y` sell = urllib.urlopen("https://sellyourstuffwhatever.com", params) 

i don't know whole lot python, i'm sure there way this. current method gives me error.

"typeerror: 'str' object not support item assignment"

edit: need able update price , amount every thirty minutes or so, done automatically script looping. website requires username, password, price , amount. username , password never change, price , amount do. there anyway can continuously update them?

urllib.urlencode [docs] returns string, not dictionary. have call after loop.

something like:

params = {'name':'xxxxx', 'pass':'xxxxxxx'}  .....:     params['amount'] = math.floor(first)     params['price'] = last*1.007-last*.003  params = urllib.urlencode(params) 

even better if use different variable name encoded string.


if don't know python yet, have @ tutorial.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -