shidebing——QandA:解决一个需求20171214
2024-09-29 00:09:43
list1 = [
{'eip': 60, 'day': '2014-7-5'},
{'etans': 96, 'day': '2014-7-5'},
{'etans': 30, 'day': '2014-4-6'},
{'eip': 100, 'day': '2014-4-6'},
] # 利用切片和zip函数,将list中的字典两辆组合成一个元组
list_temp = zip(list1[0::2], list1[1::2])
list_tuple = list(list_temp)
print(list_tuple) # 设置一个新的list容器list2,装新产生的复合日期相同,合并后的字典。
list2 = []
for tuple in list_tuple:
if tuple[0]['day'] == tuple[1]['day']:
dict_hebing = dict(tuple[0], **tuple[1])
# print(dict_hebing)
list2.append(dict_hebing)
print(list2)
仅作为参考,有弊端,慎用。
最新文章
- CAR
- 深入Java单例模式【转载】
- 【matlab】读写文件
- open/fopen read/fread write/fwrite区别
- 框架使用的技术主要是SpringMVC 在此基础上进行扩展
- hdu 5646 DZY Loves Partition 二分+数学分析+递推
- 自己封装的工具类,使用原生SwipeRefreshLayout+RecycleView实现下拉刷新和加载更多
- Delphi NativeXML 乱码的问题
- Raphael入门实例:动画与箭头
- 使用DTM ( Dynamic Topic Models )进行主题演化实验
- 关于SGA与memory_target 大小冲突照成数据库无法挂载问题
- Debug模式下程序卡
- 用SpringBoot搭建简单电商项目 01
- vuex 状态管理
- C#中d的??和?
- java去除html代码中含有的html、js、css标签,获取文字内容
- java中如何认定一个变量和方法
- Codeforces 797E - Array Queries
- Node学习笔记:建立TCP服务器和客户端之间的通信
- [穷尽]ADO.NET连接字符串
热门文章
- [Vim] 搜索模式(正则表达式)
- Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.1.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempt
- jstorm开发指南-写个简单的jstorm应用
- 通过orderby关键字,LINQ可以实现升序和降序排序。LINQ还支持次要排序。
- Android NDK学习(4)使用cygwin生成.so库文件
- mac下升级terminal/终端的subversion版本方法
- LeetCode 11 Container With Most Water(分支​判断问题)
- jenkins与SonarQube集成
- POJ 2456 Aggressive cows(二分答案)
- hihoCoder挑战赛28	题目2 : 二进制翻转