Skip to content

Instantly share code, notes, and snippets.

@makotoworld
Created December 19, 2012 04:23
Show Gist options
  • Select an option

  • Save makotoworld/4334367 to your computer and use it in GitHub Desktop.

Select an option

Save makotoworld/4334367 to your computer and use it in GitHub Desktop.

Revisions

  1. makotoworld created this gist Dec 19, 2012.
    21 changes: 21 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import simplejson

    ## 書き出し
    sample = {"@title": "みんなのPython", "author": "柴田淳", "pub": ["SoftBank Creative", "2006"]}
    file = open("sample.json", "w")
    simplejson.dump(sample, file, indent=3)
    ## sample.jsonの中身
    #{
    # "@title": "みんなのPython",
    # "pub": [
    # "SoftBank Creative",
    # "2006"
    # ],
    # "author": "柴田淳"
    #}

    ## 読み込み
    file = open("sample.json")
    a = simplejson.load(file)
    a["@title"]
    # >> u"みんなのPython"