Skip to content

Commit

Permalink
compare json
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwsir committed Nov 17, 2014
1 parent c6f38b0 commit fa84218
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 136 deletions.
12 changes: 11 additions & 1 deletion BasicPython/402.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
>He called the crowd with his disciples, and said to them,"If any want to become my followers, let them deny themseleves and take up their cross and follow me. For those who want to save their life will lose it, and those who lose their life for my sake, and for the sake fo the gospel, will save it. For what will it profit them to gain the whole world and forfeit their life? Indeed, what can they give in return for their life? Those who are ashamed of me and of my words in this adulterous and sinful generation, of them the Son of Man will also be ashamed when he comes in the glory of his Father with the holy angels."(MARK 9:34-38)
#比较json/dictionary的库

在某些情况下,比较两个json/dictionary,或许这样就可以实现:
Expand Down Expand Up @@ -30,7 +32,7 @@

方法2:到这里下载源码:https://pypi.python.org/pypi/json_tools,然后进行安装

##使用
##比较json

首先看看都有哪些属性或者方法,用万能的实验室来看:

Expand Down Expand Up @@ -71,4 +73,12 @@

这里有了一个key的嵌套字符串,在真实的使用中,有时候需要将字符串转为json的格式,即`{'prev': 3332, 'remove': '/a/aa/aaa2'}`转化为`{"a":{"aa":{"aaa2":3332}}}`

##将字符串组装成json格式

首先,回答前面的问题,可以自己写一个函数,实现那种组装。

但是,我是懒惰地程序员,我更喜欢python的原因就是它允许我懒惰。

from itertools import izip

具体这个模块如何使用,请看官到我做过的一个小项目中看看:https://github.com/qiwsir/json-diff
Empty file removed BasicPython/codes/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion BasicPython/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ python中常用的语句和类

python模块(第三方库)说明

1.[requests库](./401.md):针对http的库,比如post,get等
1. [requests库](./401.md):针对http的库,比如post,get等
2. [比较json/dictionary的库](./402.md):比较两个json,直到最底层,并将结果格式化为dict格式

###内容还在不断更新,欢迎follow me。

Expand Down
134 changes: 0 additions & 134 deletions HTML5/HTML5Lesson.md

This file was deleted.

0 comments on commit fa84218

Please sign in to comment.