# Auther: Aaron Fan

info = {
'stu1102': 'LongZe Luola',
'stu1103': 'XiaoZe Maliya',
'stu1106': 'Alex'
} #方法1(更高效)
for key in info:
print(key,info[key]) print("-----------------------------------------------")
#方法2
for k,v in info.items(): #会先把dict转成list,数据里大时莫用
print(k,v)

python3-字典的循环的更多相关文章

  1. python中字典的循环遍历的两种方式

    开发中经常会用到对于字典.列表等数据的循环遍历,但是python中对于字典的遍历对于很多初学者来讲非常陌生,今天就来讲一下python中字典的循环遍历的两种方式. 注意: python2和python ...

  2. python3 字典相关函数

    python版本3.5 #Author by Liguangbo#_*_ coding:utf-8 _*_'''info={'No.1':'ligb','No.2':'donglx','No.3':' ...

  3. python3 字典常见用法总结

    python3 字典常见用法总结 Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型. 一.创建字典 字典由键和对应值成对组成.字典也被称作关联数组或哈希表 ...

  4. 【Python】-NO.99.Note.4.Python -【Python3 条件语句 循环语句】

    1.0.0 Summary Tittle:[Python]-NO.99.Note.4.Python -[Python3 条件语句 循环语句] Style:Python Series:Python Si ...

  5. Python3 字典 get() 方法

     Python3 字典 描述 Python 字典 get() 函数返回指定键的值,如果值不在字典中返回默认值. 语法 get()方法语法: dict.get(key, default=None) 参数 ...

  6. Python3 字典 fromkeys()方法

     Python3 字典 描述 Python 字典 fromkeys() 函数用于创建一个新字典,以序列seq中元素做字典的键,value为字典所有键对应的初始值. 语法 fromkeys()方法语法: ...

  7. Python3 字典 update() 方法

     Python3 字典 描述 Python 字典 update() 函数把字典dict2的键/值对更新到dict里. 语法 update()方法语法: dict.update(dict2) 参数 di ...

  8. Python3 字典 pop() 方法

     Python3 字典 描述 Python 字典 pop() 方法删除字典给定键 key 所对应的值,返回值为被删除的值.key值必须给出. 否则,返回default值. 语法 pop()方法语法: ...

  9. Python3 字典 clear()方法

     Python3 字典 描述 Python 字典 clear() 函数用于删除字典内所有元素. 语法 clear()方法语法: dict.clear() 参数 NA. 返回值 该函数没有任何返回值. ...

  10. Python3 字典(map)

    ayout: post title: Python3 字典(map) author: "luowentaoaa" catalog: true tags: mathjax: true ...

随机推荐

  1. hdoj-3342-Legal or Not(拓扑排序)

    题目链接 /* Name:hdoj-3342-Legal or Not Copyright: Author: Date: 2018/4/11 15:59:18 Description: 判断是否存在环 ...

  2. BEC listen and translation exercise 7

    Maybe I ought to subscribe to the Engineering Quarterly.也许我应该订阅<工程学季刊>. The performance is sai ...

  3. 关于stl advance函数移动步数超过容器大小(越界)的研究

    今天使用advance遇到个问题,当advance移动步数超过容器大小时,表现的结果居然不一样. 再来看下stl源码 template<typename _BidirectionalIterat ...

  4. HDU - 5307 :He is Flying (分治+FFT)(非正解)

    JRY wants to drag racing along a long road. There are nn sections on the road, the ii-th section has ...

  5. 1151 LCA in a Binary Tree(30 分)

    The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U ...

  6. SQL夯实基础(五):索引的数据结构

    数据量达到十万级别以上的时候,索引的设置就显得异常重要,而如何才能更好的建立索引,需要了解索引的结构等基础知识.本文我们就来讨论索引的结构. 二叉搜索树:binary search tree 1.所有 ...

  7. 服务器上传大小限制 --- 来自 FastAdmin 项目开发的引发的问题 (TODO)

    服务器上传大小限制 --- 来自 FastAdmin 项目开发的引发的问题 服务器上传有几个地方修改. FastAdmin 的配置. php.ini 的配置. NGINX 的配置.

  8. 引用com.sencha.gxt.ui.GXT加载错误解决方案

    环境GWT2.7+GXT4.0 <inherits name='com.sencha.gxt.ui.GXT' /> 出现加载错误 Loading inherited module 'com ...

  9. hihoCoder#1062(最近公共祖先一)

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho最近发现了一个神奇的网站!虽然还不够像58同城那样神奇,但这个网站仍然让小Ho乐在其中,但这是为什么呢? “为什么呢 ...

  10. [转]ubuntu 网络配置 作者:Yudar

    检查网络配置命令:ifconfig 一.通过配置文件配置 新手没怎么用过Ubuntu,所以走了不少弯路,网上找了很多方法,大都没对我起到帮助作用,所以把自己的配置方法写一写. Ubuntu上连了两块网 ...