python dictionary에서 key, value change

Language/Python

2016. 4. 4. 23:28


table = {'a': 1,'b': 2,'c': 3,'d': 4,'e': 5,'f': 6,'g': 7,'h': 8,'i': 9}
v = table.values()
k = table.keys()
table.clear()
for x, y in zip(v, k) :
    table[x] = y