0

I have a dictionary that each key is unicode and I'm using the following code to insert JSON file into a dictionary.

def readDictFromFile(filename):
    my_file = Path(filename)
    if my_file.is_file():
        return json.load(codecs.open(filename,encoding='utf-8'))
    return {}

But when I try to check if a string is in the dictionary, it does not work:

if title in dict:
    continue

The reason is that the dict contains keys that look like: u'\u05d5. I say that I need to use repr (link) but is there a way to do it with the same syntax without looping for each key in the dict?

vesii
  • 2,760
  • 4
  • 25
  • 71

0 Answers0