Python的字典的items(), keys(), values()都返回一个list

     >>> dict = { 1 : 2, 'a' : 'b', 'hello' : 'world' }
>>> dict.values()
['b', 2, 'world']
>>> dict.keys()
['a', 1, 'hello']
>>> dict.items()
[('a', 'b'), (1, 2), ('hello', 'world')]
>>>

python学习之dict的items(),values(),keys()的更多相关文章

  1. Python学习——使用dict和set

    dict Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. 举个例子,假设要根据同学的名字 ...

  2. Python学习笔记—Dict和set

    dict Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. 举个例子,假设要根据同学的名字 ...

  3. python 字典 dict items values keys

    dict.items() 1 >>> d = dict(one=1,two=2) 2 >>> it1 = d.items() 3 >>> it1 ...

  4. Python学习笔记 - dict和set

    dict #!/usr/bin/env python3 # -*- coding: utf-8 -*- #dict >>> d = {'Michael': 95, 'Bob': 75 ...

  5. python 学习之dict和set类型

    什么是dict 我们已经知道,list 和 tuple 可以用来表示顺序集合,例如,班里同学的名字: ['Adam', 'Lisa', 'Bart'] 或者考试的成绩列表: [95, 85, 59] ...

  6. python学习,dict的映射练习

    练习dict的映射 #coding:utf-8 #问题: a->c, b->d, c->e... 现在有结果字符串求原字符串 dict1={'a':'c', 'b':'d', 'c' ...

  7. Python学习之dict和set

    #coding=utf-8 # dict dict= {'bob': 40, 'andy': 30} print dict['bob'] # 通过dict提供的get方法,如果key不存在,可以返回N ...

  8. python学习笔记(二)python基础知识(list,tuple,dict,set)

    1. list\tuple\dict\set d={} l=[] t=() s=set() print(type(l)) print(type(d)) print(type(t)) print(typ ...

  9. python学习笔记整理——字典

    python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返 ...

随机推荐

  1. Eclipse:快捷

    Ctrl +单击方法------------查看方法 ALT+/    -------------代码助手 Ctrl+O   -------------列出方法和成员变量或布局结构 Ctrl+D   ...

  2. Spring两种实现AOP的方式

    有两种实现AOP的方式:xml配置文件的方式和注解的形式 我们知道通知Advice是指对拦截到的方法做什么事,可以细分为 前置通知:方法执行之前执行的行为. 后置通知:方法执行之后执行的行为. 异常通 ...

  3. 在屏幕上显示C盘根目录下的所有文件和文件夹

    1 import java.io.File; //在屏幕上显示C盘根目录下的所有文件和文件夹 public class ListDemo { public static void main(Strin ...

  4. BitMask 使用参考

    对于 Java 类应用,内存方面需要注意: 不要占用大量内存,否则可用内存少:触发 GC 或 OutOfMemoryError: 不要频繁创建对象,频繁内存分配,触发 GC. 对于枚举和常量: 使用枚 ...

  5. Fucking "pkg-config not found"

    If you got pkg-config not found error in gnu auto tools then, you must install the related librarys ...

  6. 查看局域网内某个ip的mac地址

      首先需要ping一下对方的ip,确保本地的arp表中缓存对方的ip和mac的关系 C:\Windows\System32>ping 192.168.1.231 正在 Ping 192.168 ...

  7. 1227. Rally Championship

    1227 题意木看懂 是可以停在路上 任何地方 水题一枚 以下条件之一满足就可以 有环(并查集判) 重边 自己到自己的边 最长边大于s(用flod改写下) #include <iostream& ...

  8. POJ 1113 凸包模板题

    上模板. #include <cstdio> #include <cstring> #include <iostream> #include <algorit ...

  9. fil_space_create

    /*******************************************************************//** Creates a space memory obje ...

  10. [反汇编练习] 160个CrackMe之005

    [反汇编练习] 160个CrackMe之005. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...