Look up value in Django json object -


in django view have object

state_lookup = {"alabama":"al", "alaska":"ak", ... "wyoming":"wy"} 

how pass state name object , abbreviation in return?

python dictionaries can accessed in same way lists. here example.

state_lookup = {"alabama":"al", "alaska":"ak", ... "wyoming":"wy"} state = 'alabama' abbrev = state_lookup[state] # abbrev should 'al' 

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 -