用C#创建了一个json文件,发现同事用python无法读取
python 版本 :2.7
python读取json示例
# -*- coding: utf-8 -*-
import os
import json
import sys
jsonPath="F:\\eng_哈哈哈.json"
uipath = unicode(jsonPath , "utf8")
fd = open(uipath, "rb")
json_txt=json.load(fd)
print json_txt
uipath = unicode(jsonPath , "utf8")
这句可以让python读取中文文件名的文件
python 读取json 要求json文件必须是UTF-8无BOM
C# 写文件的编码:
File.WriteAllText("F:\\eng_哈哈哈.json", "要写入文件的内容", new System.Text.UTF8Encoding(false));
new System.Text.UTF8Encoding(false)
来指定编码是UTF-8 无BOM