Reputation: 991
I have a file which is simple:
# -*- coding: utf-8 -*-
a = u'Alegría'
print a
print {'a': a}
The output is:
Alegría
{'a': u'Alegr\xeda'}
Why I am getting that instead of:
Alegría
{'a': u'Alegría'}
Thanks in advance
Upvotes: 0
Views: 72
Reputation: 62948
dict
's string representation calls repr
on keys and values, and repr
tries its best to make a string representation that you can paste in any file or interpreter, with or with an encoding declared, and get the object back.
Your string is fine, it's just a safe representation.
Upvotes: 6