Skip to content

Instantly share code, notes, and snippets.

@shuivin
Created Nov 12, 2012
Embed
What would you like to do?
Python : json
"""
json的小练习,感觉下面的官方文档更好
http://docs.python.org/2/library/json.html
"""
import json
obj = [[1, 2, 3], 123, 123.123, 'abc', {'key1':(1, 2, 3) ,'key2':(4, 5, 6)}]
type(obj)
encode2json = json.dumps(obj)
print obj
print encode2json
type(encode2json)
print encode2json
encode2json1 = json.dumps(obj, indent = 2)
encode2json2 = json.dumps(obj, separator)
encode2json2 = json.dumps(obj, separators)
encode2json2 = json.dumps(obj, separators = (',',':'))
print encode2json2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment