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

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

上一篇:SpringMVC学习系列(4) 之 数据绑定-1


下一篇:深入分析 Java 中的中文编码问题