I like the Python list comprehension syntax.
Can it be used to create dictionaries too? For example, by iterating over pairs of keys and values:
mydict = {(k,v) for (k,v) in blah blah blah} # doesn't work
转载于:https://stackoverflow.com/questions/1747817/create-a-dictionary-with-list-comprehension-in-python