0

We define a dict which contains two unicode value

d={'k1': u'中文', 'k2': u'English'}

Then print the dict. The Chinese value will be printed in below behavior

print(d)
{'k2': u'English', 'k1': u'\u4e2d\u6587'}

But when print just the value, it will behave in different way

print(d['k1'])
中文

Then convert it to json and print. The behavior different again

print(json.dumps(d, indent=2))
{
  "k2": "English", 
  "k1": "\u4e2d\u6587"
}

So why the behavior change

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
Kramer Li
  • 2,284
  • 5
  • 27
  • 55

0 Answers0