Home  >  Article  >  php教程  >  Python 操作 json

Python 操作 json

WBOY
WBOYOriginal
2016-06-06 20:00:331326browse

1、安装 pip install simplejson 2、实例 import simplejson as json # 转换成json串 json. dumps (['foo', {'bar': ('baz', '白菜', 1.0, 2)}]) # json 解析 obj = json. loads ( ['foo', {'bar': ('baz', '白菜', 1.0, 2)}]) print obj[0] # 结果为: foo

1、安装

      pip install simplejson


2、实例

     import simplejson as json


     # 转换成json串

     json.dumps(['foo', {'bar': ('baz', '白菜', 1.0, 2)}])

    

    # json 解析

    obj = json.loads("['foo', {'bar': ('baz', '白菜', 1.0, 2)}]")

    print obj[0]  # 结果为: foo


来源: https://pypi.python.org/pypi/simplejson

===================  请关注  ========================

                                           Python 操作 json

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:CodeIgniter 安装Next article:Python pip 安装