當我保存與JSON一切都在文件好的,但是當我負載加載的對象是不正確的。JSON負荷是不正確的(蟒蛇)
file=open("hello", "w")
a={'name':'jason', 'age':73, 'grade':{ 'computers':97, 'physics':95, 'math':89} }
json.dump(a, file)
正如我在文件中說的那樣沒問題,但是當我加載的時候你可以看到一個問題。
文件:
" {"age": 73, "grade": {"computers": 97, "physics": 95, "math": 89}, "name": "jason"} "
現在負載:
b=json.load(file)
print b
輸出:
{u"age": 73, u"grade": {u"computers": 97, u"physics": 95, u"math": 89}, u"name": u"jason"}
你可以清楚地發現,每一個字符串之前有ü。它不影響代碼,但我不喜歡它..
爲什麼會發生這種情況?
它只是將其保存爲Unicode。 – karthikr 2013-05-14 16:28:28
http://docs.python.org/2/howto/unicode.html – root 2013-05-14 16:28:36