首页 > 编程语言 > 详细

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

时间:2014-05-19 22:54:43      阅读:806      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!