python字典操作
2016-05-19 17:09
218 查看
import json dic = { 'str': 'this is a string', 'list': [1, 2, 'a', 'b'], 'sub_dic': { 'sub_str': 'this is sub str', 'sub_list': [1, 2, 3] }, 'end': 'end' } a = json.dumps(dic) print a
输出结果: {"sub_dic": {"sub_str": "this is sub str", "sub_list": [1, 2, 3]}, "end": "end", "list": [1, 2, "a", "b"], "str": "this is a string"}
keys = ['ne_id','attached','name','devid','dev_zone_name'] values = ['ne_id','attached','name','devid','dev_zone_name'] dict(zip(self.keys, values))
将两列list组成一个dict
相关文章推荐
- python:在Django项目中使用Celery实现定时任务--简单版
- Python 面向对象(二)—— 获取对象信息
- python基础-enumerate函数和python-运算符
- python中的__dict__,__getattr__,__setattr__
- python中的 os.mkdir和os.mkdirs
- Python 面向对象
- python:使用pyquery分析html
- Python基本特性进阶
- Python学习(一 基础知识要点)
- Python 进阶 —— 函数式编程
- ubuntu14.04安装python的图像处理库PIL
- FTP使用 ---python
- python3 使用 protobuf3 序列化踩过的坑
- Python 进阶 —— 可变参数(*args, **kw)与参数收集的逆过程
- 设置python的编码
- python argparse
- python 处理 excel格式文件
- python 处理抓取网页乱码问题
- python基础列表
- 轻轻松松搞定Python基本知识小结