python dictionary(map) common flip/reverse methods

python dictionary(map) common flip/reverse methods

1:
dstDict = dict(map(reversed, srcDict.items()))

2:
dstDict = dict()
for k, v in srcDict.items():
	dstDict.setdefault(v, list().append(k))

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example