couples = [
['jack', 'ilena'],
['arun', 'maya'],
['hari', 'aradhana'],
['bill', 'samantha']]
pairs = dict(couples)

print pairs的结果为:

{'arun': 'maya', 'bill': 'samantha', 'jack': 'ilena', 'hari': 'aradhana'}

方法一:

import json
json.dumps(pairs)

方法二:

print '{%s}' % ', '.join(['"%s": "%s"' % (k, v) for k, v in pairs.items()])

转自: http://stackoverflow.com/questions/18283725/how-to-create-a-python-dictionary-with-double-quotes-as-default-quote-format

How to create a Python dictionary with double quotes as default quote format?的更多相关文章

  1. Python dictionary implementation

    Python dictionary implementation http://www.laurentluce.com/posts/python-dictionary-implementation/ ...

  2. Python dictionary 字典 常用法

    Python dictionary 字典 常用法 d = {} d.has_key(key_in)       # if has the key of key_in d.keys()          ...

  3. python:json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes问题解决

    有如下一个文件,内容如下 { "test1": "/root/test/test1.template", "test2": "/r ...

  4. JSON parser error with double quotes

    Use backslash charater \ to escape double quotes in JSON file as below example. { "myInfo" ...

  5. python基础_格式化输出(%用法和format用法)(转载)

    python基础_格式化输出(%用法和format用法) 目录 %用法 format用法 %用法 1.整数的输出 %o -- oct 八进制%d -- dec 十进制%x -- hex 十六进制 &g ...

  6. python实现float/double的0x转化

    1. 问题引出 最近遇到了一个小问题,即: 读取文本文件的内容,然后将文件中出现的数字(包括double, int, float等)转化为16进制0x存储 原本以为非常简单的内容,然后就着手去写了py ...

  7. sort a Python dictionary by value

    首先要明确一点,Python的dict本身是不能被sort的,更明确地表达应该是"将一个dict通过操作转化为value有序的列表" 有以下几种方法: 1. import oper ...

  8. python : dictionary changed size during iteration

    1. 错误方式 #这里初始化一个dict >>> d = {'a':1, 'b':0, 'c':1, 'd':0} #本意是遍历dict,发现元素的值是0的话,就删掉 >> ...

  9. PythonStudy——Python字典底层实现原理 The underlying implementation principle of Python dictionary

    在Python中,字典是通过散列表或说哈希表实现的.字典也被称为关联数组,还称为哈希数组等.也就是说,字典也是一个数组,但数组的索引是键经过哈希函数处理后得到的散列值.哈希函数的目的是使键均匀地分布在 ...

随机推荐

  1. 为什么要在游戏开发中使用ECS模式

    http://www.richardlord.net/blog/why-use-an-entity-framework Why use an entity system framework for g ...

  2. 【教程】CDQ套CDQ——四维偏序问题

    前言 上一篇文章已经介绍了简单的CDQ分治,包括经典的二维偏序和三维偏序问题,还有带修改和查询的二维/三维偏序问题.本文讲介绍多重CDQ分治的嵌套,即多维偏序问题. 四维偏序问题       给定N( ...

  3. Service实时向Activity传递数据案例

    转自 http://www.cnblogs.com/linjiqin/p/3147764.html 演示一个案例,需求如下:在Service组件中创建一个线程,该线程用来生产数值,每隔1秒数值自动加1 ...

  4. vue.js学习(第一课)

    学习资料 来自台湾小凡! vue.js是javascript的一个库,只专注于UI层面,核心价值永远是 API的简洁. 第一课: 不支持IE8. 1.声明式渲染: el元素的简称 element : ...

  5. caffe中卷积层和pooling层计算下一层的特征map的大小

    pool层,其中ceil是向上取整函数 卷积层:

  6. JAVA之IO流(字符流)

    字符流InputStreamReader和OutputStreamWriter是Writer和Read的子类:是字节流通向字符流的桥梁,也就是可以把字节流转化为字符流. InputStreamRead ...

  7. js导出excel

    function inportEx() { $("#btnEx").text("导出中..."); var fugNumber = "";/ ...

  8. ubuntu下载工具uget和aria2

    一直想在ubuntu下找到个和迅雷差不多的下载工具.在网上找到了. 这篇文章完全是抄袭整理网上的. 我的系统版本是ubuntu14.04. 1.安装uget和aria2 sudo apt-get in ...

  9. xp 下查看进程指令

    xp 下快速查看进程及关联 exe 的指令,刚发现,还没有测试 win7 和 win10 支持不支持. wmic process where creationclassname="win32 ...

  10. Dev控件GridView单元格绑定控件

    Dev控件GridView单元格绑定控件 //文本按钮 RepositoryItemButtonEdit btnFields = new RepositoryItemButtonEdit();//创建 ...