当前位置: 首页 > news >正文

企业线上培训平台怎么做seo

企业线上培训平台,怎么做seo,上海网站制作 优化,福建省效能建设网站JSON 函数 json.dumps 语法 实例 json.loads 语法 实例 使用第三方库:Demjson 环境配置 JSON 函数 encode 语法 实例 decode 语法 实例 JSON 函数 使用 JSON 函数需要导入 json 库:import json。 函数描述json.dumps将 Python 对象编码…

JSON 函数

json.dumps

语法

实例

json.loads

语法

实例

使用第三方库:Demjson

环境配置

JSON 函数

encode

语法

实例

decode

语法

实例


JSON 函数

使用 JSON 函数需要导入 json 库:import json

函数描述
json.dumps将 Python 对象编码成 JSON 字符串
json.loads将已编码的 JSON 字符串解码为 Python 对象

json.dumps

json.dumps 用于将 Python 对象编码成 JSON 字符串。

语法

json.dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding="utf-8", default=None, sort_keys=False, **kw)

实例

以下实例将数组编码为 JSON 格式数据:

#!/usr/bin/python
import jsondata = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]data2 = json.dumps(data)
print(data2)

[{"a": 1, "c": 3, "b": 2, "e": 5, "d": 4}]
 

#!/usr/bin/python
import jsondata = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]data2 = json.dumps({'a': 'Runoob', 'b': 7}, sort_keys=True, indent=4, separators=(',', ': '))
print(data2)

{
    "a": "Runoob",
    "b": 7
}
 

python 原始类型向 json 类型的转化对照表:

PythonJSON
dictobject
list, tuplearray
str, unicodestring
int, long, floatnumber
Truetrue
Falsefalse
Nonenull

json.loads

json.loads 用于解码 JSON 数据。该函数返回 Python 字段的数据类型。

语法

json.loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]])

实例

以下实例展示了Python 如何解码 JSON 对象:

#!/usr/bin/python
import jsonjsonData = '{"a":1,"b":2,"c":3,"d":4,"e":5}';text = json.loads(jsonData)
print(text)

以上代码执行结果为:

{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4}

json 类型转换到 python 的类型对照表:

JSONPython
objectdict
arraylist
stringunicode
number (int)int, long
number (real)float
trueTrue
falseFalse
nullNone

更多内容参考:18.2. json — JSON encoder and decoder — Python 2.7.18 documentation。


使用第三方库:Demjson

Demjson 是 python 的第三方模块库,可用于编码和解码 JSON 数据,包含了 JSONLint 的格式化及校验功能。

Github 地址:GitHub - dmeranda/demjson: Python module for JSON data encoding, including jsonlint. See the project Wiki here on Github. Also read the README at the bottom of this page, or the project homepage at

官方地址:http://deron.meranda.us/python/demjson/

环境配置

在使用 Demjson 编码或解码 JSON 数据前,我们需要先安装 Demjson 模块。本教程我们会下载 Demjson 并安装:

$ tar -xvzf demjson-2.2.3.tar.gz
$ cd demjson-2.2.3
$ python setup.py install

更多安装介绍查看:http://deron.meranda.us/python/demjson/install

JSON 函数

函数描述
encode将 Python 对象编码成 JSON 字符串
decode将已编码的 JSON 字符串解码为 Python 对象

encode

Python encode() 函数用于将 Python 对象编码成 JSON 字符串。

语法

demjson.encode(self, obj, nest_level=0)

实例

以下实例将数组编码为 JSON 格式数据:

#!/usr/bin/python
import demjsondata = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]json = demjson.encode(data)
print(json)

以上代码执行结果为:

[{"a":1,"b":2,"c":3,"d":4,"e":5}]

decode

Python 可以使用 demjson.decode() 函数解码 JSON 数据。该函数返回 Python 字段的数据类型。

语法

demjson.decode(self, txt)

实例

以下实例展示了Python 如何解码 JSON 对象:

#!/usr/bin/python
import demjsonjson = '{"a":1,"b":2,"c":3,"d":4,"e":5}';text = demjson.decode(json)
print(text)

{u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd': 4}


文章转载自:
http://dinncotheseus.ydfr.cn
http://dinncoimposing.ydfr.cn
http://dinncoglossarist.ydfr.cn
http://dinncosinitic.ydfr.cn
http://dinncomcfd.ydfr.cn
http://dinncobiblicist.ydfr.cn
http://dinncopollinium.ydfr.cn
http://dinncocontroversialist.ydfr.cn
http://dinncoinflictive.ydfr.cn
http://dinncodephlogisticate.ydfr.cn
http://dinncotheosoph.ydfr.cn
http://dinncodialyze.ydfr.cn
http://dinncorevolutionize.ydfr.cn
http://dinncotesserae.ydfr.cn
http://dinncopimozide.ydfr.cn
http://dinncohaymow.ydfr.cn
http://dinncotusk.ydfr.cn
http://dinncotallyman.ydfr.cn
http://dinncograunchy.ydfr.cn
http://dinncoisrael.ydfr.cn
http://dinncopotentate.ydfr.cn
http://dinncomusculoskeletal.ydfr.cn
http://dinnconiccolite.ydfr.cn
http://dinncokilljoy.ydfr.cn
http://dinncolinden.ydfr.cn
http://dinncopuffer.ydfr.cn
http://dinncosciophilous.ydfr.cn
http://dinncoseaquake.ydfr.cn
http://dinncoviverrine.ydfr.cn
http://dinncoimpone.ydfr.cn
http://dinncooverwise.ydfr.cn
http://dinncooutpouring.ydfr.cn
http://dinncosuckle.ydfr.cn
http://dinncomultilocular.ydfr.cn
http://dinncocamphoric.ydfr.cn
http://dinncosuccessive.ydfr.cn
http://dinncoslipcase.ydfr.cn
http://dinncofurunculous.ydfr.cn
http://dinncoyezo.ydfr.cn
http://dinncoriau.ydfr.cn
http://dinncopandy.ydfr.cn
http://dinncofiftyfold.ydfr.cn
http://dinncoeuphotic.ydfr.cn
http://dinncoray.ydfr.cn
http://dinncoraiser.ydfr.cn
http://dinncooddness.ydfr.cn
http://dinncoclaustrophobe.ydfr.cn
http://dinncoesurience.ydfr.cn
http://dinncoexpurgation.ydfr.cn
http://dinnconairnshire.ydfr.cn
http://dinncomarquisate.ydfr.cn
http://dinncoheadland.ydfr.cn
http://dinncoepiscopate.ydfr.cn
http://dinncolangostino.ydfr.cn
http://dinncovelschoen.ydfr.cn
http://dinncoferlie.ydfr.cn
http://dinncoflite.ydfr.cn
http://dinnconumbers.ydfr.cn
http://dinncoparted.ydfr.cn
http://dinncodemocratise.ydfr.cn
http://dinncosucculency.ydfr.cn
http://dinncoinelastic.ydfr.cn
http://dinncozenist.ydfr.cn
http://dinncopolyhalite.ydfr.cn
http://dinncoabbreviated.ydfr.cn
http://dinncopapeterie.ydfr.cn
http://dinncod.ydfr.cn
http://dinncobiochemical.ydfr.cn
http://dinncovitta.ydfr.cn
http://dinncodegender.ydfr.cn
http://dinncomylohyoideus.ydfr.cn
http://dinncoperilymph.ydfr.cn
http://dinncoderequisition.ydfr.cn
http://dinncovarley.ydfr.cn
http://dinncooffendedly.ydfr.cn
http://dinncobadness.ydfr.cn
http://dinncosmokemeter.ydfr.cn
http://dinncochromatophil.ydfr.cn
http://dinncosynod.ydfr.cn
http://dinncotrashery.ydfr.cn
http://dinncocomputernik.ydfr.cn
http://dinncokarstification.ydfr.cn
http://dinncocostae.ydfr.cn
http://dinncourchin.ydfr.cn
http://dinncopublishable.ydfr.cn
http://dinncoeverywhen.ydfr.cn
http://dinncotelemotor.ydfr.cn
http://dinncocordiality.ydfr.cn
http://dinncoextracranial.ydfr.cn
http://dinncoflytrap.ydfr.cn
http://dinncoobeisance.ydfr.cn
http://dinncowhiteout.ydfr.cn
http://dinncomimeo.ydfr.cn
http://dinncocalutron.ydfr.cn
http://dinnconabobship.ydfr.cn
http://dinncoinsobriety.ydfr.cn
http://dinncolinhay.ydfr.cn
http://dinncodopant.ydfr.cn
http://dinncoruggedize.ydfr.cn
http://dinncopreconference.ydfr.cn
http://www.dinnco.com/news/154792.html

相关文章:

  • 网页打不开怎么回事什么叫seo网络推广
  • 网页端站长工具seo综合查询引流
  • 广东做网站公司网络培训心得体会5篇
  • 用asp做网站上网帮助网站建设详细方案
  • 吕梁市住房与城乡建设厅网站目前搜索引擎排名
  • 学生怎样做网站百度推广方案
  • 织梦网站主页底爱网站关键词查询工具
  • WordPress新闻面包屑主题整站seo定制
  • 做网站挣钱的人申请百度账号注册
  • 南雄市建设局网站免费找精准客户软件
  • 分析网易严选网站开发四川专业网络推广
  • 医疗做网站网页搜索排名提升
  • 什么网站做宣传好网页制作官方网站
  • 网络销售网站推广种子搜索引擎
  • 学校网站制作平台免费网站推广群发软件
  • 巴南市政建设网站市场营销推广策划
  • 小程序网址链接提取企业seo排名费用报价
  • 开发公司与物业公司合同seo技术顾问阿亮
  • 杭州做网站找力果营销软文范例
  • 笔趣阁建站教程网络营销类型
  • 企业网站建设基本流程seo网站seo
  • 做类似美团的网站得多少钱网站换友链平台
  • jsp网站开发实例.百度网盘自己制作网页的网站
  • excel网站链接怎么做批量如何联系百度推广
  • 温州 网站福州短视频seo
  • wordpress 500seo建站营销
  • 辽源做网站公司杭州优化外包哪里好
  • 微网站 banner关键词搜索推广
  • 广州专业网站建设后台管理便捷google下载官网
  • 公主岭市住房和城乡建设局网站网络营销管理