[Tutor] How can I see properly my korean.
kent37 at tds.net
Thu May 31 15:09:04 CEST 2007
Young-gyu Park wrote:
> fileHandle = open (
> '/var/chroot/www/htdocs/django/js/model.js', 'w' )
> fileHandle.write( codecs.BOM_UTF8 )
> print >> fileHandle, 'var blog = '
> print >> fileHandle, blog
> This is the part of my whole source code.
OK, blog is a dict containing nested dicts. The problem is that printing
a dict prints the repr() of the contents of the dict, which gives you
the \x escapes for your strings.
Since you are clearly using Django, I suggest you use the simplejson
module to do the serialization as I showed in my previous email. Instead of
print >> fileHandle, blog
print >> fileHandle, dumps(blog, ensure_ascii=False)
where dumps is imported from django.utils.simplejson
More information about the Tutor