博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python方法items_Python字典items()方法与示例
阅读量:2530 次
发布时间:2019-05-11

本文共 1181 字,大约阅读时间需要 3 分钟。

python方法items

字典items()方法 (Dictionary items() Method)

items() method is used to get the all items as a view object, the view object represents the key-value pair of the dictionary.

items()方法用于获取所有项目作为视图对象,该视图对象表示字典的键值对。

Syntax:

句法:

dictionary_name.items()

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is <class 'dict_items'>, it returns the items of the dictionary as view object.

此方法的返回类型为<class'dict_items'> ,它将字典的项目作为视图对象返回。

Example:

例:

# Python Dictionary items() Method with Example# dictionary declarationstudent = {
"roll_no": 101, "name": "Shivang", "course": "B.Tech", "perc" : 98.5}# printing dictionaryprint("data of student dictionary...")print(student)# printing itemsprint("items of student dictionary...")print(student.items())# printing return type of student.items() Methodprint("return type is: ", type(student.items()))

Output

输出量

data of student dictionary...{'name': 'Shivang', 'perc': 98.5, 'roll_no': 101, 'course': 'B.Tech'}items of student dictionary...dict_items([('name', 'Shivang'), ('perc', 98.5), ('roll_no', 101), ('course', 'B.Tech')])return type is:  

翻译自:

python方法items

转载地址:http://arxzd.baihongyu.com/

你可能感兴趣的文章
又漏一次
查看>>
dede模板中plus文件路径使用方法
查看>>
xml解析demo使用
查看>>
python使用模板手记
查看>>
No result defined for action com.nynt.action.ManageAction and result input问题
查看>>
iOS开发拓展篇—UIDynamic(重力行为+碰撞检测)
查看>>
洛谷 P3627 [APIO2009](抢掠计划 缩点+spfa)
查看>>
c++ 连接数据库
查看>>
函数指针与回调函数
查看>>
你所不知道的 CSS 滤镜技巧与细节
查看>>
hack reviewboard 让 FireFox 把 tab 显示为 4 或 2 个空格
查看>>
css 学习整理
查看>>
录制游戏视频——fraps
查看>>
jQuery 停止动画
查看>>
HTML基础之JS
查看>>
01背包问题python 2.7实现
查看>>
E - Kagome Kagome
查看>>
Android Studio Errors
查看>>
软件工程第二次作业—结对编程
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>