# 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的更多相关文章

  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. sort a Python dictionary by value

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

  4. python : dictionary changed size during iteration

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

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

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

  6. python dictionary的遍历

    d = {'x':1, 'y':3, 'z':2} for k in d:    print d[k] 直接遍历k in d的话,遍历的是dictionary的keys. 2 字典的键可以是任何不可变 ...

  7. Python dictionary 字典

    Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型. 一.创建字典字典由键和对应值成对组成.字典也被称作关联数组或哈希表.基本语法如下: dict = {' ...

  8. How to create a Python dictionary with double quotes as default quote format?

    couples = [ ['jack', 'ilena'], ['arun', 'maya'], ['hari', 'aradhana'], ['bill', 'samantha']] pairs = ...

  9. Python攻关之Django(一)

    课程简介: Django流程介绍 Django url Django view Django models Django template Django form Django admin (后台数据 ...

随机推荐

  1. ASP.NET MVC下使用AngularJs语言(四):$window.alert

    判断文本框是否有填写,没有填写使用angularjs的$window.alert来提示用户. 创建一个ASP.NET MVC控制器: 接下来是准备一个angularjs的控制器: pilotApp.c ...

  2. springboot之定时任务

    定时线程 说到定时任务,通常会想到JDK自带的定时线程来执行,定时任务. 回顾一下定时线程池. public static ScheduledExecutorService newScheduledT ...

  3. OkHttp 入门篇

    OkHttp是一个HTTP & HTTP2的客户端,能够用来进行Android 和 Java 开发. HTTP是现代应用的最基本的网络环境.让你的HTTP更加有效的工作能够让你的东西加载更快而 ...

  4. linux下tar.bz2文件的 解压缩方法

    一 使用bzip2解压缩命令进行解压缩: bzip2 -d  gcc-4.1.0.tar.bz2 二 上面解压完之后执行下面的命令. tar -xvf gcc-4.1.0.tar 或 tar -xvf ...

  5. Testing - 软件测试知识梳理 - 比较质量保证(QA)与质量控制(QC)

    QA QC QM 概念 Quality Assurance (质量保证) Quality Control (质量控制) Quality Manage (质量管理) 定义 为达到质量要求所采取的作业技术 ...

  6. centos7不小心删除了/etc/yum.repos.d/CentOS-Base.repo文件..........

    一步小心使用rm -rf /etc/yum.repos.d/CentOS-Base.repo 删除了base.repo文件,导致使用yum安装时报错. 解决如下,使用阿里云的镜像: wget -O / ...

  7. Liferay7 BPM门户开发之19: 理解Service Builder体系

    Service Builder是Liferay为业务开发而设计的模型驱动(model-driven)平台工具,提供一系列的实体类.数据持久化.服务相关的代码自动生成服务.支持Hibernate and ...

  8. [EXP]K8 DotNetNuke DNNspot Store <=3.0 GetShell exploit

    # Exploit Title: DotNetNuke DNNspot Store <=3.0 GetShell exploit# Date: 31/03/2015# Author: K8拉登哥 ...

  9. 你(可能)不知道的web api

    你(可能)不知道的web api 简介 作为前端er,我们的工作与web是分不开的,随着HTML5的日益壮大,浏览器自带的webapi也随着增多.本篇文章主要选取了几个有趣且有用的webapi进行介绍 ...

  10. eclipse引入php源包

    首先安装这些yum install gcc gcc-c++ kernel-devel autoconf automake libtool bison re2c gdb 导入时,如果有这个报错的话 Pr ...