Is it possible in Python to use Unicode characters as keys for a dictionary?
I have Cyrillic words in Unicode that I used as keys. When trying to get a value by a key, I get the following traceback:
Traceback (most recent call last):
File "baseCreator.py", line 66, in <module>
createStoresTable()
File "baseCreator.py", line 54, in createStoresTable
region_id = regions[region]
KeyError: u'\u041c\u0438\u043d\u0441\u043a/\u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0438\u0439\xa0'
Yes, it’s possible. The error you’re getting means that the key you’re using doesn’t exist in your dictionary.
To debug, try
printing your dictionary; you’ll see the repr of each key which should show what the actual key looks like.