码迷,mamicode.com
首页 > 编程语言 > 详细

Python load json file with UTF-8 BOM header - Stack Overflow

时间:2014-05-19 23:02:20      阅读:507      评论:0      收藏:0      [点我收藏+]

标签:class   c   code   ext   http   int   

Python load json file with UTF-8 BOM header - Stack Overflow


12
down vote

accepted

You can open with codecs:

import json
import codecs

json.load(codecs.open(‘sample.json‘,‘r‘,‘utf-8-sig‘))

or decode with utf-8-sig yourself and pass to loads:

json.loads(open(‘sample.json‘).read().decode(‘utf-8-sig‘))

Python load json file with UTF-8 BOM header - Stack Overflow,布布扣,bubuko.com

Python load json file with UTF-8 BOM header - Stack Overflow

标签:class   c   code   ext   http   int   

原文地址:http://www.cnblogs.com/lexus/p/3731344.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!