Created
January 30, 2017 15:28
-
-
Save guerbai/0c187901de22321681eff48309cf46af to your computer and use it in GitHub Desktop.
Python输出格式化带中文的json文件.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import json | |
import codecs | |
a = { "name": "一个"} | |
b = json.dumps(a, indent=4) | |
print type(b) | |
f = codecs.open('test3.py', 'wb', encoding='utf-8') | |
f.write(b.decode("unicode_escape")) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment