Python:dictionary
# Python3.4 Eclipse+PyDev 打开Eclipse,找到Help菜单栏,进入Install New Software…选项。
# 点击work with:输入框的旁边点击Add…,Name可以随便是什么,我输入的是PyDev,Location是http://pydev.org/updates。点击OK。
import json
import os
import nltk
import collections
import heapq
import operator
import itertools sent=["In","the","beginning","God","created"];
wo=nltk.bigrams(sent);
for w in wo:
print(w); #字典 geovindu 塗聚文
prices={"ACME":45.23,"APPLE":612.79,"IBM":205.55,"HP":37.20,"FB":10.67};
min_prices=min(zip(prices.values(),prices.keys()));
max_prices=max(zip(prices.values(),prices.keys()));
sort_prices=sorted(zip(prices.values(),prices.keys()));
name_prices=min(prices,key=lambda k:prices[k]); max_pricesstr=max(zip(prices.values(),prices.keys())); print("最小值對應值:"+name_prices); for mi in min_prices:
print(mi) #print(min_prices);
#print(max_prices);
#print(sort_prices); print("排序:");
for mis in sort_prices:
print(mis)
print("最高股票:");
for mix in max_prices:
print(mix) #字典中查相同點
dirA={
"geovindu":32,
"塗聚文":28,
"江東":12,
"劉若英":40,
"english":22
} dirB={
"涂聚文":28,
"江苏":32,
"刘若英":40,
"江東":12,
"geovindu":32,
"english":22 }
dirkey=dirA.keys()&dirB.keys();
dirvalues=dirA.items()&dirB.items(); print("keys:")
print(dirkey);
print("values:")
print(dirvalues)
Python:dictionary的更多相关文章
- Python dictionary implementation
Python dictionary implementation http://www.laurentluce.com/posts/python-dictionary-implementation/ ...
- Python dictionary 字典 常用法
Python dictionary 字典 常用法 d = {} d.has_key(key_in) # if has the key of key_in d.keys() ...
- sort a Python dictionary by value
首先要明确一点,Python的dict本身是不能被sort的,更明确地表达应该是"将一个dict通过操作转化为value有序的列表" 有以下几种方法: 1. import oper ...
- python : dictionary changed size during iteration
1. 错误方式 #这里初始化一个dict >>> d = {'a':1, 'b':0, 'c':1, 'd':0} #本意是遍历dict,发现元素的值是0的话,就删掉 >> ...
- PythonStudy——Python字典底层实现原理 The underlying implementation principle of Python dictionary
在Python中,字典是通过散列表或说哈希表实现的.字典也被称为关联数组,还称为哈希数组等.也就是说,字典也是一个数组,但数组的索引是键经过哈希函数处理后得到的散列值.哈希函数的目的是使键均匀地分布在 ...
- python dictionary的遍历
d = {'x':1, 'y':3, 'z':2} for k in d: print d[k] 直接遍历k in d的话,遍历的是dictionary的keys. 2 字典的键可以是任何不可变 ...
- Python dictionary 字典
Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型. 一.创建字典字典由键和对应值成对组成.字典也被称作关联数组或哈希表.基本语法如下: dict = {' ...
- How to create a Python dictionary with double quotes as default quote format?
couples = [ ['jack', 'ilena'], ['arun', 'maya'], ['hari', 'aradhana'], ['bill', 'samantha']] pairs = ...
- Python攻关之Django(一)
课程简介: Django流程介绍 Django url Django view Django models Django template Django form Django admin (后台数据 ...
随机推荐
- Shell - 简明Shell入门14 - 操作符(Operator)
示例脚本及注释 #!/bin/bash echo "No code, just some comments." # ### 通配符 # * 代表任意(0个或多个)字符 # ? 代表 ...
- Spring MVC & Boot & Cloud 技术教程汇总(长期更新)
昨天我们发布了Java成神之路上的知识汇总,今天继续. Java成神之路技术整理(长期更新) 以下是Java技术栈微信公众号发布的关于 Spring/ Spring MVC/ Spring Boot/ ...
- spring boot -thymeleaf-域对象操作
后台代码
- vue 组件发布记录
好久没做独立的 vue 组件了,最近突然想把一个常用的 vue 组件打成一个 npm 包,方便使用.好久不用,发现已经忘记环境怎么搭建.翻看以前的组件,才慢慢回想起来,中间还出现些错误.在这记录下开发 ...
- Cookie的存储、获取、删除操作
var Cookie={ set: function (name, value, days) { var d = new Date; d.setTime(d.getTime() + 24*60*60* ...
- Angular学习第一步
前端开发越来越流行了,作为后端开发人员,也开始需要学习前端了.随着前端技术的发展,前端技术也越来越复杂,复杂程度不亚于后端,各种框架各种设计模式前端都用上了,什么AngularJS,Angular, ...
- git第十节--git hub
github 是一个开源的协作社区 github 插件octtree 为别人的仓库做贡献 fork 别人仓库内容到自己的个人仓库 git clone 到本地进行开发push 到个人仓库 提PR(pul ...
- 在Android项目中使用AspectJ
版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请表明出处:http://www.cnblogs.com/cavalier-/p/8888459.html 什么是AOP AOP是 Aspec ...
- 初学javaScript推荐工具
对于刚开始学习js的同学,强烈推荐直接使用chrome developer mode,超级方便. 随便打开一个网页,开启开发者模式即可写js代码,不用新建html和js文件即可看到自己写的js代码的结 ...
- Keepalived原理与实战精讲
什么是Keepalived呢,keepalived观其名可知,保持存活,在网络里面就是保持在线了,也就是所谓的高可用或热备,用来防止单点故障(单点故障是指一旦某一点出现故障就会导致整个系统架构的不可用 ...