加载本地json:

with open('./test.json', 'r') as f:
data = json.load(f)


删除json中一个元素
# -*- coding=utf8 -*-
import io
import urllib2
from urllib2 import urlopen
from PIL import Image
import json


if __name__ == '__main__':
    with open('j', 'r') as f:
        data = json.load(f)

    ll = data['list']
    for user in ll:
        if user['url'] == '5348728':
            print 'find it!'
            ll.remove(user)


    for user in data['list']:
        if user['url'] == '5348728':
            print 'find it!'

    with open('j', 'w') as f:
        f.write(json.dumps(data))

 

相关文章:

  • 2021-10-14
  • 2021-11-18
  • 2021-08-31
  • 2021-06-20
  • 2021-12-18
  • 2021-06-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2021-06-24
  • 2022-01-08
  • 2022-02-08
  • 2021-08-25
  • 2021-12-29
相关资源
相似解决方案