-1

i has some json works like this.

>>> j = '{"a":5}'
>>> js = json.loads(j)
>>> for key in js:
...     key
...     type(key)
...     key is unicode('a')
... 
u'a'
<type 'unicode'>
False

In my opinion last value of output should be true. Plese helpme to find my mistake.

wrufesh
  • 1,379
  • 3
  • 18
  • 36

1 Answers1

0

Why are you using is here? You just want to compare:

key == unicode('a')

or even better:

key == u'a'
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895