1
votes

I am trying to pass UTF-8 encoded file containing one JSON Object.

{ "problemList": [
    {
        "subject": "사회",
        "category": "영수증회계",
        "problemText": " "
    }
]}

In python2.7, I want to read subject and category field with format like this:

print "<font name=\"Hangul\" size=\"8\">%s, %s</font>" % (problem_list[0]['subject'], problem_list[0]['category'])

However it gives me error

Error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xeb in position 0: ordinal not in range(128)

Why python throws this error?

1

1 Answers

0
votes

Have you tried with unicode string?

Just change "blah-blah" to u"blah-blah". It works for me.

print u"<font name=\"Hangul\" size=\"8\">%s, %s</font>" % (problem_list[0]['subject'], problem_list[0]['category'])