Hi im jaychung

I am still me as long as my spirit is free.

使用 Python 處理中文 JSON

最近在處理大量的中文 json 檔案,一直遇到編碼上的問題,相信大家也都有遇過,

1
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-10: ordinal not in range(128)

也就是 ascii 無法順利編碼,最後得到了一個解決方法:調整 ensure_ascii 參數以及使用codecs

我們用example.json當做範例:

1
2
3
4
5
6
7
8
9
10
[
{
"category": "數位生活",
"content": "<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322265\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1434509582.jpg?v=1430390937\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">之前也有跟各位推薦過可以將照片上傳的空間</span></p>\r\n<p><span style=\"font-size: 12pt;\"><!-- more --></span></p>\r\n<p><span style=\"background-color: #ffff99; font-size: 12pt;\"><a style=\"color: #000000; text-decoration: none;\" href=\"http://mulicia.pixnet.net/blog/post/30366011\"><span style=\"background-color: #ffff99;\">保存相片的優質網路硬碟 Onedrive</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\">但是Onedrive改版之後竟然出現略過上傳非照片的項目,所以今天我們來使用另一款容量更大,而且不挑照片的雲端空間</span></p>\r\n<p><span style=\"font-size: 12pt;\">首先,你要先註冊mega</span></p>\r\n<p><span style=\"font-size: 12pt;\">這邊可以下載:</span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8\"><span style=\"background-color: #ffff99;\">點我</span></a></span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8\"><span style=\"background-color: #ffff99;\">https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\">或是直接在網頁註冊與登錄</span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://mega.co.nz\"><span style=\"background-color: #ffff99;\">https://mega.co.nz</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"https://mega.co.nz\"><img src=\"//pic.pimg.tw/mulicia/1430391239-3045295675_n.png?v=1430391243\" alt=\"\" />&nbsp;</a></span></p>\r\n<p><span style=\"font-size: 12pt;\">進入app之後,就會顯示資料夾,</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322268\"><img src=\"//pic.pimg.tw/mulicia/1430390908-2790753504_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">然後我們要點選最右邊的設定,就會出現你的資料,你可以看到mega很大方的直接給你50GB</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322274\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1097207413_n.png?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">選擇「相機上傳」後,再選擇「啟用相機上傳」</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322277\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1890808202_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">接著他就會讀取你所有的照片,此時建議你直接將「所有照片」打勾</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322283\"><img src=\"//pic.pimg.tw/mulicia/1430390909-2881366005_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">順便將下面的「上傳影片」、「使用蜂窩連結」(吃到飽用戶才可以)、還有「定期在後台運行」都打開</span></p>\r\n<p><span style=\"font-size: 12pt;\">接著他就會自己啟動上傳了,而且會建立一個「camera uploads」的資料夾</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322280\"><img src=\"//pic.pimg.tw/mulicia/1430390910-4258887413_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">點進去就可以看到妳現在的上傳進度</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322286\"><img src=\"//pic.pimg.tw/mulicia/1430390910-2687319340_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">你也可以選取下方標籤的照片</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322295\"><img src=\"//pic.pimg.tw/mulicia/1430390911-3551332594_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">他會有一個時間排序,但是沒有設計得很好就是了。</span></p>\r\n<p><span style=\"font-size: 12pt;\">但是使用這類的雲端空間還有一個最大的好處,就是你可以直接用電腦的瀏覽器開啟你的照片:</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326060\"><img src=\"//pic.pimg.tw/mulicia/1430397430-1126872681_n.png?v=1430397441\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">當然也可以全部下載回電腦,便於整理還有備份</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326063\"><img src=\"//pic.pimg.tw/mulicia/1430397430-1377224561.png?v=1430397441\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326057\"><img src=\"//pic.pimg.tw/mulicia/1430397431-280304841.png?v=1430397441\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">我特別安裝windows的版本給大家看一下:</span></p>\r\n<p><span style=\"font-size: 16px;\"><a href=\"http://mulicia.pixnet.net/album/photo/290381656\"><img src=\"//pic.pimg.tw/mulicia/1430509343-1599476045_n.png?v=1430509348\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">下載或是上傳是會有背景工具</span></p>\r\n<p><span style=\"font-size: 16px;\">你就可以直接在檔案總管裡面編輯他了</span></p>\r\n<p><span style=\"font-size: 16px;\"><a href=\"http://mulicia.pixnet.net/album/photo/290381653\"><img src=\"//pic.pimg.tw/mulicia/1430509343-1916039122_l.jpg?v=1430509348\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">是不是很方便呢?</span></p>\r\n<p><span style=\"font-size: 12pt;\">&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">&nbsp;</span></p>"
},
{
"category": "生活綜合",
"content": "<p class=\"p1\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158456\"><img src=\"//pic.pimg.tw/mulicia/1430024642-369828413_m.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">多年前的今天,發生了車諾比事件,這是人類史上的災難,也是第一個對人類造成重大傷亡的民用核子反應器意外。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">但是今天我會特別寫這篇,是因為早上看到一位我很敬重的醫療人員前輩發了相關文章,看完內容後覺得蠻難過的,所以我決定來寫一下。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\"><!-- more --></span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158471\"><img src=\"//pic.pimg.tw/mulicia/1430024647-253166502_m.png?v=1430024671\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">但是車諾比真的在經歷這麼多年後,是像描述中的一樣,大部分區域不適合居住?</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">整個環境像是凍結在意外發生的那一刻嗎?</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">首先,我們可以用google map來確認一下:</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158468\"><img src=\"//pic.pimg.tw/mulicia/1430024644-3760290675_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158465\"><img src=\"//pic.pimg.tw/mulicia/1430024645-2424389282_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158474\"><img src=\"//pic.pimg.tw/mulicia/1430024646-1149668415_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">google map雖然不是即時更新,但是也不會超過3年太多,所以看起來是還好呀,而且還是有人。</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">至於動物,可能因為人類不敢靠近,反而活的更好 (在車諾比禁區的狐狸)</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><iframe src=\"https://www.youtube.com/embed/bfhd6tdRC9A\" width=\"640\" height=\"360\" frameborder=\"0\" title=\"YouTube video player\" allowfullscreen=\"\"></iframe> &nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">sciencedaily的報導:<a href=\"http://www.sciencedaily.com/releases/2012/04/120411084107.htm\">http://www.sciencedaily.com/releases/2012/04/120411084107.htm</a></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\">Wildlife thriving after nuclear disaster? Radiation from Chernobyl and Fukushima nuclear accidents not as harmful to wildlife as feared</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159179\"><img src=\"//pic.pimg.tw/mulicia/1430025216-3397665887_n.png?v=1430025222\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">University of Portsmouth大學的教授, 吉姆&bull;史密斯 (Jim Smith), 以及來自西英格蘭大學的同事們, 質疑早期車諾比核災事故對鳥類影響的研究.</span></p>\r\n<p><span style=\"font-size: 12pt;\">科學家一直以來認為車諾比輻射會傷害鳥類抗氧化機制. 但史密斯教授及其同事,第一次量化這種效果. 他們發現鳥類的抗氧化機制可以很容易地應對車諾比輻射水平.</span></p>\r\n<p><span style=\"font-size: 12pt;\">車諾比事故後,極高的輻射水平傷害生物。但現在,車諾比輻射水平已下降幾百倍. 雖然一些研究似乎看到動物的長期影響, 其他研究沒有發現任何影響.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">實際上,車諾比隔離區的野生動物恢復的很好, 甚至比核災前更好.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">史密斯教授研究車諾比核災污染超過20年,並定期到禁區研究野生動物.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">WNN的報導:<a href=\"http://www.world-nuclear-news.org/EE-Biosphere-reserve-for-Chernobyl-0708201401.html\">http://www.world-nuclear-news.org/EE-Biosphere-reserve-for-Chernobyl-0708201401.html</a></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><strong>Biosphere reserve for Chernobyl</strong></span></p>\r\n<p><span style=\"font-size: 12pt;\">烏克蘭希望盡快準備一份總統令草案,在車諾比禁區建立生物圈保護區。</span><br /><span style=\"font-size: 12pt;\">&ldquo;在過去的28年,車諾比地區已被保護,今天那裡開展了一個獨特的情況 - 無論是植物和動物都在積極成長和恢復.&rdquo;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159224\"><img src=\"//pic.pimg.tw/mulicia/1430025308-1985520992_n.png?v=1430025313\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">4/25/2015 目前車諾比輻射圖<a href=\"https://chernobyl-tour.com/chernobyl_zone_map_en.html\">https://chernobyl-tour.com/chernobyl_zone_map_en.html</a></span></p>\r\n<p><span style=\"font-size: 12pt;\">Kiev 0.12 uSi/hr</span><br /><span style=\"font-size: 12pt;\">車諾比 0.17 uSi/hr</span><br /><span style=\"font-size: 12pt;\">車諾比核電廠 4.26 uSi/hr</span><br /><span style=\"font-size: 12pt;\">紐約 0.11 uSi/hr</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159263\"><img src=\"//pic.pimg.tw/mulicia/1430025431-4062675227_n.png\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">也有人有拍影片</span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><strong>Postcards from Pripyat, Chernobyl</strong></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><iframe src=\"https://player.vimeo.com/video/112681885\" width=\"500\" height=\"213\" frameborder=\"0\" webkitallowfullscreen=\"\" mozallowfullscreen=\"\" allowfullscreen=\"\"></iframe></span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"https://vimeo.com/112681885\">Postcards from Pripyat, Chernobyl</a> from <a href=\"https://vimeo.com/dannycooke\">Danny Cooke</a> on <a href=\"https://vimeo.com\">Vimeo</a>.</span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\">&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">看起來應該都還好吧,並沒有想像中的嚴重,人類最擔心的核子能怪獸也沒有出現....</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159338\"><img src=\"//pic.pimg.tw/mulicia/1430025630-741946193_n.jpg?v=1430025635\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">專業人士遇到自己不熟悉的專業的時候,要拿出更多一倍、兩倍甚至三杯以上的努力來學習與查證,而且要用比自己專業更為謹慎的態度來看待。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">尤其是醫療人員,因為是專業的指標象徵,所以更要注意自己的言行。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">所以為了釐清前輩的清白,還有對我所有的讀者交代,甚至是給台灣民眾一個真相,我決定公開募款去福島還有車諾比與白俄羅斯一趟。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">拍下為數驚人的照片、環場還有影片給我所有的讀者,當然贊助者也可以提出你的要求看你想要看到什麼或是視訊也可以。</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">怕輻射的人不用擔心,FaceTime只會傳送影像,不會傳核子能,希望能成行!</span></p>"
}
]

先套用這份程式碼單純讀入寫出,

1
2
3
4
5
6
7
8
#-*- coding: utf8 -*-
import json

with open('example.json', 'rb') as fin:
json_data = json.loads(fin.read().decode('utf8'))

with open("example-out.json", "w") as fout:
fout.write(json.dumps(is_spam, indent=4))

會得到這個結果:

1
2
3
4
5
6
7
8
9
10
[
{
"category": "\u6578\u4f4d\u751f\u6d3b",
"content": "<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322265\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1434509582.jpg?v=1430390937\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4e4b\u524d\u4e5f\u6709\u8ddf\u5404\u4f4d\u63a8\u85a6\u904e\u53ef\u4ee5\u5c07\u7167\u7247\u4e0a\u50b3\u7684\u7a7a\u9593</span></p>\r\n<p><span style=\"font-size: 12pt;\"><!-- more --></span></p>\r\n<p><span style=\"background-color: #ffff99; font-size: 12pt;\"><a style=\"color: #000000; text-decoration: none;\" href=\"http://mulicia.pixnet.net/blog/post/30366011\"><span style=\"background-color: #ffff99;\">\u4fdd\u5b58\u76f8\u7247\u7684\u512a\u8cea\u7db2\u8def\u786c\u789f Onedrive</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4f46\u662fOnedrive\u6539\u7248\u4e4b\u5f8c\u7adf\u7136\u51fa\u73fe\u7565\u904e\u4e0a\u50b3\u975e\u7167\u7247\u7684\u9805\u76ee\uff0c\u6240\u4ee5\u4eca\u5929\u6211\u5011\u4f86\u4f7f\u7528\u53e6\u4e00\u6b3e\u5bb9\u91cf\u66f4\u5927\uff0c\u800c\u4e14\u4e0d\u6311\u7167\u7247\u7684\u96f2\u7aef\u7a7a\u9593</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9996\u5148\uff0c\u4f60\u8981\u5148\u8a3b\u518amega</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9019\u908a\u53ef\u4ee5\u4e0b\u8f09\uff1a</span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8\"><span style=\"background-color: #ffff99;\">\u9ede\u6211</span></a></span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8\"><span style=\"background-color: #ffff99;\">https://itunes.apple.com/tw/app/mega/id706857885?l=zh&amp;mt=8</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\">\u6216\u662f\u76f4\u63a5\u5728\u7db2\u9801\u8a3b\u518a\u8207\u767b\u9304</span></p>\r\n<p><span style=\"font-size: 12pt; background-color: #ffff99;\"><a href=\"https://mega.co.nz\"><span style=\"background-color: #ffff99;\">https://mega.co.nz</span></a></span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"https://mega.co.nz\"><img src=\"//pic.pimg.tw/mulicia/1430391239-3045295675_n.png?v=1430391243\" alt=\"\" />&nbsp;</a></span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9032\u5165app\u4e4b\u5f8c\uff0c\u5c31\u6703\u986f\u793a\u8cc7\u6599\u593e\uff0c</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322268\"><img src=\"//pic.pimg.tw/mulicia/1430390908-2790753504_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u7136\u5f8c\u6211\u5011\u8981\u9ede\u9078\u6700\u53f3\u908a\u7684\u8a2d\u5b9a\uff0c\u5c31\u6703\u51fa\u73fe\u4f60\u7684\u8cc7\u6599\uff0c\u4f60\u53ef\u4ee5\u770b\u5230mega\u5f88\u5927\u65b9\u7684\u76f4\u63a5\u7d66\u4f6050GB</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322274\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1097207413_n.png?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9078\u64c7\u300c\u76f8\u6a5f\u4e0a\u50b3\u300d\u5f8c\uff0c\u518d\u9078\u64c7\u300c\u555f\u7528\u76f8\u6a5f\u4e0a\u50b3\u300d</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322277\"><img src=\"//pic.pimg.tw/mulicia/1430390908-1890808202_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u63a5\u8457\u4ed6\u5c31\u6703\u8b80\u53d6\u4f60\u6240\u6709\u7684\u7167\u7247\uff0c\u6b64\u6642\u5efa\u8b70\u4f60\u76f4\u63a5\u5c07\u300c\u6240\u6709\u7167\u7247\u300d\u6253\u52fe</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322283\"><img src=\"//pic.pimg.tw/mulicia/1430390909-2881366005_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9806\u4fbf\u5c07\u4e0b\u9762\u7684\u300c\u4e0a\u50b3\u5f71\u7247\u300d\u3001\u300c\u4f7f\u7528\u8702\u7aa9\u9023\u7d50\u300d\uff08\u5403\u5230\u98fd\u7528\u6236\u624d\u53ef\u4ee5\uff09\u3001\u9084\u6709\u300c\u5b9a\u671f\u5728\u5f8c\u53f0\u904b\u884c\u300d\u90fd\u6253\u958b</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u63a5\u8457\u4ed6\u5c31\u6703\u81ea\u5df1\u555f\u52d5\u4e0a\u50b3\u4e86\uff0c\u800c\u4e14\u6703\u5efa\u7acb\u4e00\u500b\u300ccamera uploads\u300d\u7684\u8cc7\u6599\u593e</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322280\"><img src=\"//pic.pimg.tw/mulicia/1430390910-4258887413_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u9ede\u9032\u53bb\u5c31\u53ef\u4ee5\u770b\u5230\u59b3\u73fe\u5728\u7684\u4e0a\u50b3\u9032\u5ea6</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322286\"><img src=\"//pic.pimg.tw/mulicia/1430390910-2687319340_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4f60\u4e5f\u53ef\u4ee5\u9078\u53d6\u4e0b\u65b9\u6a19\u7c64\u7684\u7167\u7247</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290322295\"><img src=\"//pic.pimg.tw/mulicia/1430390911-3551332594_n.jpg?v=1430391243\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4ed6\u6703\u6709\u4e00\u500b\u6642\u9593\u6392\u5e8f\uff0c\u4f46\u662f\u6c92\u6709\u8a2d\u8a08\u5f97\u5f88\u597d\u5c31\u662f\u4e86\u3002</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4f46\u662f\u4f7f\u7528\u9019\u985e\u7684\u96f2\u7aef\u7a7a\u9593\u9084\u6709\u4e00\u500b\u6700\u5927\u7684\u597d\u8655\uff0c\u5c31\u662f\u4f60\u53ef\u4ee5\u76f4\u63a5\u7528\u96fb\u8166\u7684\u700f\u89bd\u5668\u958b\u555f\u4f60\u7684\u7167\u7247\uff1a</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326060\"><img src=\"//pic.pimg.tw/mulicia/1430397430-1126872681_n.png?v=1430397441\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u7576\u7136\u4e5f\u53ef\u4ee5\u5168\u90e8\u4e0b\u8f09\u56de\u96fb\u8166\uff0c\u4fbf\u65bc\u6574\u7406\u9084\u6709\u5099\u4efd</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326063\"><img src=\"//pic.pimg.tw/mulicia/1430397430-1377224561.png?v=1430397441\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290326057\"><img src=\"//pic.pimg.tw/mulicia/1430397431-280304841.png?v=1430397441\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">\u6211\u7279\u5225\u5b89\u88ddwindows\u7684\u7248\u672c\u7d66\u5927\u5bb6\u770b\u4e00\u4e0b\uff1a</span></p>\r\n<p><span style=\"font-size: 16px;\"><a href=\"http://mulicia.pixnet.net/album/photo/290381656\"><img src=\"//pic.pimg.tw/mulicia/1430509343-1599476045_n.png?v=1430509348\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">\u4e0b\u8f09\u6216\u662f\u4e0a\u50b3\u662f\u6703\u6709\u80cc\u666f\u5de5\u5177</span></p>\r\n<p><span style=\"font-size: 16px;\">\u4f60\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728\u6a94\u6848\u7e3d\u7ba1\u88e1\u9762\u7de8\u8f2f\u4ed6\u4e86</span></p>\r\n<p><span style=\"font-size: 16px;\"><a href=\"http://mulicia.pixnet.net/album/photo/290381653\"><img src=\"//pic.pimg.tw/mulicia/1430509343-1916039122_l.jpg?v=1430509348\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p><span style=\"font-size: 16px;\">\u662f\u4e0d\u662f\u5f88\u65b9\u4fbf\u5462\uff1f</span></p>\r\n<p><span style=\"font-size: 12pt;\">&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">&nbsp;</span></p>"
},
{
"category": "\u751f\u6d3b\u7d9c\u5408",
"content": "<p class=\"p1\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158456\"><img src=\"//pic.pimg.tw/mulicia/1430024642-369828413_m.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u591a\u5e74\u524d\u7684\u4eca\u5929\uff0c\u767c\u751f\u4e86\u8eca\u8afe\u6bd4\u4e8b\u4ef6\uff0c\u9019\u662f\u4eba\u985e\u53f2\u4e0a\u7684\u707d\u96e3\uff0c\u4e5f\u662f\u7b2c\u4e00\u500b\u5c0d\u4eba\u985e\u9020\u6210\u91cd\u5927\u50b7\u4ea1\u7684\u6c11\u7528\u6838\u5b50\u53cd\u61c9\u5668\u610f\u5916\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u4f46\u662f\u4eca\u5929\u6211\u6703\u7279\u5225\u5beb\u9019\u7bc7\uff0c\u662f\u56e0\u70ba\u65e9\u4e0a\u770b\u5230\u4e00\u4f4d\u6211\u5f88\u656c\u91cd\u7684\u91ab\u7642\u4eba\u54e1\u524d\u8f29\u767c\u4e86\u76f8\u95dc\u6587\u7ae0\uff0c\u770b\u5b8c\u5167\u5bb9\u5f8c\u89ba\u5f97\u883b\u96e3\u904e\u7684\uff0c\u6240\u4ee5\u6211\u6c7a\u5b9a\u4f86\u5beb\u4e00\u4e0b\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\"><!-- more --></span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158471\"><img src=\"//pic.pimg.tw/mulicia/1430024647-253166502_m.png?v=1430024671\" alt=\"\" /></a>&nbsp;&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u4f46\u662f\u8eca\u8afe\u6bd4\u771f\u7684\u5728\u7d93\u6b77\u9019\u9ebc\u591a\u5e74\u5f8c\uff0c\u662f\u50cf\u63cf\u8ff0\u4e2d\u7684\u4e00\u6a23\uff0c\u5927\u90e8\u5206\u5340\u57df\u4e0d\u9069\u5408\u5c45\u4f4f\uff1f</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u6574\u500b\u74b0\u5883\u50cf\u662f\u51cd\u7d50\u5728\u610f\u5916\u767c\u751f\u7684\u90a3\u4e00\u523b\u55ce\uff1f</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u9996\u5148\uff0c\u6211\u5011\u53ef\u4ee5\u7528google map\u4f86\u78ba\u8a8d\u4e00\u4e0b\uff1a</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158468\"><img src=\"//pic.pimg.tw/mulicia/1430024644-3760290675_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158465\"><img src=\"//pic.pimg.tw/mulicia/1430024645-2424389282_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290158474\"><img src=\"//pic.pimg.tw/mulicia/1430024646-1149668415_n.png?v=1430024671\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">google map\u96d6\u7136\u4e0d\u662f\u5373\u6642\u66f4\u65b0\uff0c\u4f46\u662f\u4e5f\u4e0d\u6703\u8d85\u904e3\u5e74\u592a\u591a\uff0c\u6240\u4ee5\u770b\u8d77\u4f86\u662f\u9084\u597d\u5440\uff0c\u800c\u4e14\u9084\u662f\u6709\u4eba\u3002</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u81f3\u65bc\u52d5\u7269\uff0c\u53ef\u80fd\u56e0\u70ba\u4eba\u985e\u4e0d\u6562\u9760\u8fd1\uff0c\u53cd\u800c\u6d3b\u7684\u66f4\u597d \uff08\u5728\u8eca\u8afe\u6bd4\u7981\u5340\u7684\u72d0\u72f8\uff09</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><iframe src=\"https://www.youtube.com/embed/bfhd6tdRC9A\" width=\"640\" height=\"360\" frameborder=\"0\" title=\"YouTube video player\" allowfullscreen=\"\"></iframe> &nbsp;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">sciencedaily\u7684\u5831\u5c0e\uff1a<a href=\"http://www.sciencedaily.com/releases/2012/04/120411084107.htm\">http://www.sciencedaily.com/releases/2012/04/120411084107.htm</a></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\">Wildlife thriving after nuclear disaster? Radiation from Chernobyl and Fukushima nuclear accidents not as harmful to wildlife as feared</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159179\"><img src=\"//pic.pimg.tw/mulicia/1430025216-3397665887_n.png?v=1430025222\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">University of Portsmouth\u5927\u5b78\u7684\u6559\u6388, \u5409\u59c6&bull;\u53f2\u5bc6\u65af (Jim Smith), \u4ee5\u53ca\u4f86\u81ea\u897f\u82f1\u683c\u862d\u5927\u5b78\u7684\u540c\u4e8b\u5011, \u8cea\u7591\u65e9\u671f\u8eca\u8afe\u6bd4\u6838\u707d\u4e8b\u6545\u5c0d\u9ce5\u985e\u5f71\u97ff\u7684\u7814\u7a76.</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u79d1\u5b78\u5bb6\u4e00\u76f4\u4ee5\u4f86\u8a8d\u70ba\u8eca\u8afe\u6bd4\u8f3b\u5c04\u6703\u50b7\u5bb3\u9ce5\u985e\u6297\u6c27\u5316\u6a5f\u5236. \u4f46\u53f2\u5bc6\u65af\u6559\u6388\u53ca\u5176\u540c\u4e8b\uff0c\u7b2c\u4e00\u6b21\u91cf\u5316\u9019\u7a2e\u6548\u679c. \u4ed6\u5011\u767c\u73fe\u9ce5\u985e\u7684\u6297\u6c27\u5316\u6a5f\u5236\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u61c9\u5c0d\u8eca\u8afe\u6bd4\u8f3b\u5c04\u6c34\u5e73.</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u8eca\u8afe\u6bd4\u4e8b\u6545\u5f8c\uff0c\u6975\u9ad8\u7684\u8f3b\u5c04\u6c34\u5e73\u50b7\u5bb3\u751f\u7269\u3002\u4f46\u73fe\u5728\uff0c\u8eca\u8afe\u6bd4\u8f3b\u5c04\u6c34\u5e73\u5df2\u4e0b\u964d\u5e7e\u767e\u500d. \u96d6\u7136\u4e00\u4e9b\u7814\u7a76\u4f3c\u4e4e\u770b\u5230\u52d5\u7269\u7684\u9577\u671f\u5f71\u97ff, \u5176\u4ed6\u7814\u7a76\u6c92\u6709\u767c\u73fe\u4efb\u4f55\u5f71\u97ff.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u5be6\u969b\u4e0a,\u8eca\u8afe\u6bd4\u9694\u96e2\u5340\u7684\u91ce\u751f\u52d5\u7269\u6062\u5fa9\u7684\u5f88\u597d, \u751a\u81f3\u6bd4\u6838\u707d\u524d\u66f4\u597d.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">\u53f2\u5bc6\u65af\u6559\u6388\u7814\u7a76\u8eca\u8afe\u6bd4\u6838\u707d\u6c61\u67d3\u8d85\u904e20\u5e74\uff0c\u4e26\u5b9a\u671f\u5230\u7981\u5340\u7814\u7a76\u91ce\u751f\u52d5\u7269.</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\">WNN\u7684\u5831\u5c0e\uff1a<a href=\"http://www.world-nuclear-news.org/EE-Biosphere-reserve-for-Chernobyl-0708201401.html\">http://www.world-nuclear-news.org/EE-Biosphere-reserve-for-Chernobyl-0708201401.html</a></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><strong>Biosphere reserve for Chernobyl</strong></span></p>\r\n<p><span style=\"font-size: 12pt;\">\u70cf\u514b\u862d\u5e0c\u671b\u76e1\u5feb\u6e96\u5099\u4e00\u4efd\u7e3d\u7d71\u4ee4\u8349\u6848,\u5728\u8eca\u8afe\u6bd4\u7981\u5340\u5efa\u7acb\u751f\u7269\u5708\u4fdd\u8b77\u5340\u3002</span><br /><span style=\"font-size: 12pt;\">&ldquo;\u5728\u904e\u53bb\u768428\u5e74,\u8eca\u8afe\u6bd4\u5730\u5340\u5df2\u88ab\u4fdd\u8b77\uff0c\u4eca\u5929\u90a3\u88e1\u958b\u5c55\u4e86\u4e00\u500b\u7368\u7279\u7684\u60c5\u6cc1 - \u7121\u8ad6\u662f\u690d\u7269\u548c\u52d5\u7269\u90fd\u5728\u7a4d\u6975\u6210\u9577\u548c\u6062\u5fa9.&rdquo;</span></p>\r\n<p class=\"p2\"><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159224\"><img src=\"//pic.pimg.tw/mulicia/1430025308-1985520992_n.png?v=1430025313\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">4/25/2015 \u76ee\u524d\u8eca\u8afe\u6bd4\u8f3b\u5c04\u5716<a href=\"https://chernobyl-tour.com/chernobyl_zone_map_en.html\">https://chernobyl-tour.com/chernobyl_zone_map_en.html</a></span></p>\r\n<p><span style=\"font-size: 12pt;\">Kiev 0.12 uSi/hr</span><br /><span style=\"font-size: 12pt;\">\u8eca\u8afe\u6bd4 0.17 uSi/hr</span><br /><span style=\"font-size: 12pt;\">\u8eca\u8afe\u6bd4\u6838\u96fb\u5ee0 4.26 uSi/hr</span><br /><span style=\"font-size: 12pt;\">\u7d10\u7d04 0.11 uSi/hr</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159263\"><img src=\"//pic.pimg.tw/mulicia/1430025431-4062675227_n.png\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u4e5f\u6709\u4eba\u6709\u62cd\u5f71\u7247</span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><strong>Postcards from Pripyat, Chernobyl</strong></span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\"><iframe src=\"https://player.vimeo.com/video/112681885\" width=\"500\" height=\"213\" frameborder=\"0\" webkitallowfullscreen=\"\" mozallowfullscreen=\"\" allowfullscreen=\"\"></iframe></span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"https://vimeo.com/112681885\">Postcards from Pripyat, Chernobyl</a> from <a href=\"https://vimeo.com/dannycooke\">Danny Cooke</a> on <a href=\"https://vimeo.com\">Vimeo</a>.</span></p>\r\n<p class=\"p1\"><span class=\"s1\" style=\"font-size: 12pt;\">&nbsp;</span></p>\r\n<p><span style=\"font-size: 12pt;\">\u770b\u8d77\u4f86\u61c9\u8a72\u90fd\u9084\u597d\u5427\uff0c\u4e26\u6c92\u6709\u60f3\u50cf\u4e2d\u7684\u56b4\u91cd\uff0c\u4eba\u985e\u6700\u64d4\u5fc3\u7684\u6838\u5b50\u80fd\u602a\u7378\u4e5f\u6c92\u6709\u51fa\u73fe....</span></p>\r\n<p><span style=\"font-size: 12pt;\"><a href=\"http://mulicia.pixnet.net/album/photo/290159338\"><img src=\"//pic.pimg.tw/mulicia/1430025630-741946193_n.jpg?v=1430025635\" alt=\"\" /></a>&nbsp;</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u5c08\u696d\u4eba\u58eb\u9047\u5230\u81ea\u5df1\u4e0d\u719f\u6089\u7684\u5c08\u696d\u7684\u6642\u5019\uff0c\u8981\u62ff\u51fa\u66f4\u591a\u4e00\u500d\u3001\u5169\u500d\u751a\u81f3\u4e09\u676f\u4ee5\u4e0a\u7684\u52aa\u529b\u4f86\u5b78\u7fd2\u8207\u67e5\u8b49\uff0c\u800c\u4e14\u8981\u7528\u6bd4\u81ea\u5df1\u5c08\u696d\u66f4\u70ba\u8b39\u614e\u7684\u614b\u5ea6\u4f86\u770b\u5f85\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u5c24\u5176\u662f\u91ab\u7642\u4eba\u54e1\uff0c\u56e0\u70ba\u662f\u5c08\u696d\u7684\u6307\u6a19\u8c61\u5fb5\uff0c\u6240\u4ee5\u66f4\u8981\u6ce8\u610f\u81ea\u5df1\u7684\u8a00\u884c\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u6240\u4ee5\u70ba\u4e86\u91d0\u6e05\u524d\u8f29\u7684\u6e05\u767d\uff0c\u9084\u6709\u5c0d\u6211\u6240\u6709\u7684\u8b80\u8005\u4ea4\u4ee3\uff0c\u751a\u81f3\u662f\u7d66\u53f0\u7063\u6c11\u773e\u4e00\u500b\u771f\u76f8\uff0c\u6211\u6c7a\u5b9a\u516c\u958b\u52df\u6b3e\u53bb\u798f\u5cf6\u9084\u6709\u8eca\u8afe\u6bd4\u8207\u767d\u4fc4\u7f85\u65af\u4e00\u8d9f\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u62cd\u4e0b\u70ba\u6578\u9a5a\u4eba\u7684\u7167\u7247\u3001\u74b0\u5834\u9084\u6709\u5f71\u7247\u7d66\u6211\u6240\u6709\u7684\u8b80\u8005\uff0c\u7576\u7136\u8d0a\u52a9\u8005\u4e5f\u53ef\u4ee5\u63d0\u51fa\u4f60\u7684\u8981\u6c42\u770b\u4f60\u60f3\u8981\u770b\u5230\u4ec0\u9ebc\u6216\u662f\u8996\u8a0a\u4e5f\u53ef\u4ee5\u3002</span></p>\r\n<p class=\"p1\"><span style=\"font-size: 12pt;\">\u6015\u8f3b\u5c04\u7684\u4eba\u4e0d\u7528\u64d4\u5fc3\uff0cFaceTime\u53ea\u6703\u50b3\u9001\u5f71\u50cf\uff0c\u4e0d\u6703\u50b3\u6838\u5b50\u80fd\uff0c\u5e0c\u671b\u80fd\u6210\u884c\uff01</span></p>"
}
]

這樣的輸出內容並不符合我們的需求,但如果修改 ensure_ascii 以及使用codecs,

1
2
3
4
5
6
7
8
9
10
#-*- coding: utf8 -*-

import json
import codecs

with open('example.json', 'rb') as fin:
json_data = json.loads(fin.read().decode('utf8'))

with codecs.open("example-out.json", "w", encoding="utf8") as fout:
json.dump(json_data, fout, ensure_ascii=False, indent=4)

我們就能得到跟原本一樣內容的輸出,也就是編碼過的json。

Proudly powered by Hexo and Theme by Hacker
© 2019 Jay Chung