t = json.dumps(r, ensure_ascii=False) html
若是 不加 ensure_ascii=False 輸出的 t 若是有漢字的話都默認給轉換成一堆編碼 若是加上的話 就都能正常顯示變成了漢字json
例如:編碼
不加的話: t = json.dumps(r)url
- [{"category": {"label": "\u65b0\u8f66"}, "title": "\u5168\u65b0\u8d77\u4e9a\u798f\u745e\u8fea\u8def\u8bd5\u8c0d\u7167\u66dd\u5149 \u6216\u4e3a\u5b9a\u540dK3", "url": "http://auto.sohu.com/20120523/n343878794.shtml", "source": "\u641c\u72d0\u6c7d\u8f66", "time": 1337740004, "imgUrl": ""}, {"category": {"label": "\u65b0\u8f66"}, "title": "\u65b0\u5965\u8feaQ7/Q8\u66f4\u591a\u4fe1\u606f\u66dd\u5149 \u5c06\u57fa\u4e8eMLB\u5e73\u53f0", "url": "http://auto.sohu.com/20120523/n343873150.shtml", "source": "\u641c\u72d0\u6c7d\u8f66", "time": 1337737913, "imgUrl": ""}]
加上的話: t = json.dumps(r, ensure_ascii=False)htm
- [{"category": {"label": "新車"}, "title": "全新起亞福瑞迪路試諜照曝光 或爲定名K3", "url": "http://auto.sohu.com/20120523/n343878794.shtml", "source": "汽車", "time": 1337740004, "imgUrl": ""}, {"category": {"label": "新車"}, "title": "新奧迪Q7/Q8更多信息曝光 將基於MLB平臺", "url": "http://auto.sohu.com/20120523/n343873150.shtml", "source": "汽車", "time": 1337737913, "imgUrl": ""}]