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
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
 
    
    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.
