zoukankan      html  css  js  c++  java
  • Python之json

    加载本地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))
  • 相关阅读:
    Python 学习目录
    Django目录
    SQLAlchemy
    Flask之Sqlalchemy
    Websocket
    Mongodb
    虚拟环境
    Github
    LINUX
    内存管理和垃圾回收机制
  • 原文地址:https://www.cnblogs.com/huangshiyu13/p/6240099.html
Copyright © 2011-2022 走看看