What is the python items function? How to use it? |
您所在的位置:网站首页 › pythonitems函数怎么用 › What is the python items function? How to use it? |
In this article, let’s learn about the python items function in the python dictionary. What does the items function mean? What effect does this function have? Get the answer in the following article. Description Python Dictionary (Dictionary) items() function returns a traversable array of (key, value) tuples as a list. Syntax items() method syntax: dict.items()Copy after loginParameters ##NA.Return value Returns a traversable array of (key, value) tuples.Example The following example shows how to use the items() function: # !/usr/bin/python # coding=utf-8 dict = {'Google': 'www.google.com', 'Runoob': 'www.runoob.com', 'taobao': 'www.taobao.com'} print "字典值 : %s" % dict.items() # 遍历字典列表 for key, values in dict.items(): print key, valuesCopy after loginThe output result of the above example is: 字典值 : [('Google', 'www.google.com'), ('taobao', 'www.taobao.com'), ('Runoob', 'www.runoob.com')] Google www.google.com taobao www.taobao.com Runoob www.runoob.comCopy after loginThe above is all the content of this article, the built-in items function of the dictionary in python. I hope what I said and the examples I gave can be helpful to you. For more related knowledge, please visit thePython tutorial column on the php Chinese website. The above is the detailed content of What is the python items function? How to use it?. For more information, please follow other related articles on the PHP Chinese website! |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |