对 list 遍历

a_list = [1,2,3]
for index,iterm in enumerate(a_list):
print(index,iterm)

对 dict 遍历

dict = {"yellow":1, "red":2}
for k, v in dict.items():
print(k,v)

enumerate 和 dict.items()的更多相关文章

  1. dict.items vs six.iteritems

    python2里面,dict.items返回的是数组,six.iteritems(dict)则返回生成器. 意味着,dict很大的时候,后者不占用内存. >>> import six ...

  2. python 字典 dict items values keys

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

  3. Python--字典的一些用法dict.items()

    1.dict.items() 例子1: 以列表返回可遍历的(键, 值) 元组数组. dict = {'Name': 'Runoob', 'Age': 7} print ("Value : % ...

  4. Python3基础 dict items 以元组的形式打印出字典的每一个项

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  5. python新手必躺的5大坑

    python新手必躺的5大坑 对于Python新手来说,写代码很少考虑代码的效率和简洁性,因此容易造成代码冗长.执行慢,这些都是需要改进的地方.本文是想通过几个案列给新手一点启发,怎样写python代 ...

  6. python学习之dict的items(),values(),keys()

    Python的字典的items(), keys(), values()都返回一个list >>> dict = { 1 : 2, 'a' : 'b', 'hello' : 'worl ...

  7. Python dict get items pop update

    一.get方法 dict = {'k1':1,'k2':2} dict.get('k1') 1 dict.get('k2') 2 dict.get('k3') None dict.get('k3',' ...

  8. 字典dict的深入学习(item() / items() 一致的)

    字典Dict的跟进学习: 一. items()方法的遍历:items()方法把字典中每对key和value组成一个元组,并把这些元组放在列表中返回. dict = {"name" ...

  9. python3基础: 元组tuple、 列表list、 字典dict、集合set。 迭代器、生成器

    一.元组: tuple Python 的元组与列表类似,不同之处在于元组的元素不能修改. 元组中的元素值是不允许删除的,但我们可以使用del语句来删除整个元组 tup2 = (111, 22, 33, ...

随机推荐

  1. forbidden Derby database starting with weblogic instance

    Now doing a new project  which  choose the newest weblogic 12.1.2.0.0 as web container.But found the ...

  2. js 实现 一张图片的上传

    .js进行图片预览 使用input标签来选择图片,使用FileReader读取图片并转成base64编码,然后发送给服务器. <html> <body> <img id= ...

  3. 【独家】阿里天池IJCAI17大赛第四名方案全解析(附代码)

    [独家]阿里天池IJCAI17大赛第四名方案全解析(附代码) https://mp.weixin.qq.com/s?__biz=MzAxMzA2MDYxMw==&mid=2651560625& ...

  4. SpringBoot简单理解

    SpringBoot 一.特点:1.默认大于配置,不需要大量配置文件,没有web.xml,拥有可运行的Application类. 2.一般通过java代码配置,而尽量少使用xml配置. 3.maven ...

  5. 寻找hash值——把int array看成是一个整数

    QUESTION: Write a class DominoChecker that has a method called addBox(int[]) that takes a box of fiv ...

  6. MongoDB中使用的SCRAM-SHA1认证机制

    摘要: 介绍 SCRAM是密码学中的一种认证机制,全称Salted Challenge Response Authentication Mechanism. SCRAM适用于使用基于『用户名:密码』这 ...

  7. App启动页设计实例与技巧

    App启动页,也称闪屏页,最初是为缓解用户等待Web/iOS/Android App数据加载的焦虑情绪而出现,后被设计师巧妙用于品牌文化展示,服务特色介绍以及功能界面熟悉等平台进行设计,被赋予了更加丰 ...

  8. Button或者ImageButton的背景设为透明或者半透明

    Button或者ImageButton的背景设为透明或者半透明 半透明<Button android:background="#e0000000" ... /> 透明& ...

  9. 前端福利之jQuery文字轮播特效(转)

    闲谈:离开学校那座象牙塔已经也有大半年的事件了,生活中不再充满了茫然只有忙碌.连续加班加点大半个月,做的活动项目终于算是告一段落了,而今天也将是考验其真正价值的时候,现在将这次开发中遇到的问题做一下总 ...

  10. Python之模块和包学习

    模块简介 python是由一系列的模块组成的,每个模块就是一个py为后缀的文件,同时模块也是一个命名空间,从而避免了变量名称冲突的问题.模块我们就可以理解为lib库,如果需要使用某个模块中的函数或对象 ...