问题
What I came up with is:
keys, values = zip(*[(key, value) for (key, value) in my_dict.iteritems()])
But I am not satisfied. What do the pythonistas say?
回答1:
What about using my_dict.keys() and my_dict.values()?
keys, values = my_dict.keys(), my_dict.values()
回答2:
keys, values = zip(*d.items())
来源:https://stackoverflow.com/questions/6612769/is-there-a-more-elegant-way-for-unpacking-keys-and-values-of-a-dictionary-into-t