Python中如何通过一个JSON中个数据更新另外一个JSON?
PHP中文网
PHP中文网 2017-04-17 17:32:04
0
2
223

有一个JSON数据保存在本地(约2000条数据),程序运行后会去服务器加载一个最近更新的JSON数据列表(30条,但这里可能会含有本地中已经有的数据),怎么样才可以比较高效的更新本地的JSON数据为最新?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
阿神

Because I don’t know the form of your data, I can only say - list storage is a linear time update, saving space and time: If it is a dictionary key-value的形式是O(1)complexity update. Trade space for time.

迷茫

If it is in k-v format, you can convert it to dict first, and then update

old = {"a":1,"b":2}
new = {"a":2,"c":3}
old.update(new)
# old={"a":2,"b":2,"c":3}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!