# 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. linux shell 学习笔记--文件测试符

    . 文件测试操作 ---------------- 返回true 如果... -e 文件存在 -a 文件存在 这个选项的效果与-e 相同.但是它已经被弃用了,并且不鼓励使用 -f file 是一个re ...

  2. CodeForces - 138C: Mushroom Gnomes - 2 (线段树&概率&排序)

    One day Natalia was walking in the woods when she met a little mushroom gnome. The gnome told her th ...

  3. grep---Linux下文本处理五大神器之五

    转自:http://www.cnblogs.com/dong008259/archive/2011/12/12/2285264.html grep是linux中很常用的一个命令,主要功能就是进行字符串 ...

  4. Phone numbers

    Phone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, ...

  5. 【转】浅谈Java中的equals和==

    浅谈Java中的equals和== 在初学Java时,可能会经常碰到下面的代码: String str1 = new String("hello"); String str2 = ...

  6. bzoj 3028 食物——生成函数

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3028 把式子写出来,化一化,变成 x / ((1-x)^4) ,变成几个 sigma 相乘的 ...

  7. C# 多线程参数传递

    之前使用多线程的时候,基本没有遇到过参数传递的情况,最近,接连遇到需要进行参数传递的多线程的使用.每次都要重新上网查一下,太麻烦了.为了方便以后的使用,就把经常参阅的网上资料记录下来. 原文地址如下: ...

  8. 容器中跨主机的网络方案-flannel

    容器中的网络是建立docker集群的重要内容. 本文将介绍如何用flannel实现容器的多节点互通. 下图是flannel的实现原理,摘自: http://docker-k8s-lab.readthe ...

  9. C Primer Plus学习笔记(六)- C 控制语句:分支和跳转

    if 语句: if 语句被称为分支语句(branching statement)或选择语句(selection statement) if 语句的通用形式: if (expression) state ...

  10. 通过phpMyAdmin拿webshell

    general_log默认为关闭的,root权限开启后,general_log_file会保存所有的查询语句 所以可以开启general_log,然后设置general_log_file为一个php文 ...