# encoding:utf-8
import json
data={"user":"张三","sex":"男"}
f = open("/home/alpha/Desktop/test1","w")
f.write(json.dumps(data,ensure_ascii=False,encoding='utf-8'))
f.close()
d = open("/home/alpha/Desktop/test1","r")
print d.read()
d.close()
## 注 最好使用 codecs
imoprt codecs
f = codecs.open()
ensure_ascii=False,encoding='utf-8' 这两项不设置的话 会自动存U码