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

values() method is used to get all values of a dictionary, it returns a view object that contains the all values of the dictionary as a list.

values()方法用于获取字典的所有值,它返回一个包含字典所有值的列表的视图对象。

Syntax:

句法:

    dictionary_name.values()

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is <class 'dict_values'>, it returns all values as a view object that contains a list of all values.

此方法的返回类型为<class'dict_values'> ,它将所有值作为包含所有值列表的视图对象返回。

Example:

例:

# Python Dictionary values() Method with Example
# dictionary declaration
student = {"roll_no": 101,
"name": "Shivang",
"course": "B.Tech",
"perc" : 98.5
}
# printing dictionary
print("data of student dictionary...")
print(student)
# getting all values
x = student.values()
print(x)
# printing type of values() Method
print('Type is: ',type(student.values()))
# changing the value
# it will effect the value of view object also
student['course'] = 'MCA'
# printing dictionary
print("data of student dictionary...")
print(student)
# getting all values
x = student.values()
print(x)

Output

输出量

data of student dictionary...
{'roll_no': 101, 'name': 'Shivang', 'course': 'B.Tech', 'perc': 98.5}
dict_values([101, 'Shivang', 'B.Tech', 98.5])
Type is:  <class 'dict_values'>
data of student dictionary...
{'roll_no': 101, 'name': 'Shivang', 'course': 'MCA', 'perc': 98.5}
dict_values([101, 'Shivang', 'MCA', 98.5])

翻译自: https://www.includehelp.com/python/dictionary-values-method-with-example.aspx

Python字典values()方法与示例相关推荐

  1. Python 字典 values() 方法

    描述 Python 字典 values() 方法以列表形式(并非直接的列表,若要返回列表值还需调用list函数)返回字典中的所有值. 语法 values() 方法语法: D.values() 参数 无 ...

  2. [转载] Python3 字典 values() 方法

    参考链接: Python字典values() 描述 Python 字典 values() 方法返回一个迭代器,可以使用 list() 来转换为列表,列表为字典中的所有值. 语法 values()方法语 ...

  3. Python字典使用方法大全

    Python字典使用方法大全 python中还有一种数据结构特别重要,就是字典.字典是键(key)-值(value)一一对应组成.这样的键-值组合叫做项.键与值之间用':'分隔,项之间用','分隔. ...

  4. Python 字典 fromkeys()方法

    Python 字典 fromkeys() 方法用于创建一个新的字典,并以可迭代对象中的元素分别作为字典中的键,且所有键对应同一个值,默认为None. fromkeys() 方法语法: 1 dict.f ...

  5. 用来处理python字典的方法_python字典的常用方法总结

    python中字典是非常常用的数据类型,了解各种方法的作用及优缺点对于字典的使用非常有用. dict.clear() 的方法用于清空所有的键值对,清空后字典变成空字典.代码示例如下: data = { ...

  6. [Python] 字典 items()方法:同时对字典的键和值进行遍历

    描述: Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组. 语法: dict.items() 返回值: 返回可遍历的(键, 值) 元组数组. 主 ...

  7. Python 字典 items()方法

    Python 字典 items() 函数作用:以列表返回可遍历的(键, 值) 元组数组. items()方法语法: dict.items() 操作方法: dict = {'老大':'15岁','老二' ...

  8. python forward(10)什么意思-Python turtle.forward方法代码示例

    本文整理汇总了Python中turtle.forward方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.forward方法的具体用法?Python turtle.forwar ...

  9. Python cv2.minMaxLoc方法代码示例

    本文整理汇总了Python中cv2.minMaxLoc方法的典型用法代码示例.如果您正苦于以下问题:Python cv2.minMaxLoc方法的具体用法?Python cv2.minMaxLoc怎么 ...

最新文章

  1. 某字节程序员求助:家庭条件比leader好很多,leader还没买房,但自己已准备买车买房,会不会被仇富?网友:收敛点,别露富!...
  2. linux中iso文件怎么安装系统文件,我有linux的iso文件,要怎么安装系统
  3. H3C交换机典型访问控制列表(ACL)配置实例
  4. Python案例:格式化输出斐波拉契数列
  5. 正则表达式学习笔记004--连字符和范围描述符的认识与应用
  6. “技术·探索”技术作家英雄会带你开启不一样的1024!
  7. Nginx怎么打开目录浏览功能
  8. 朱石景 201671010457 团队项目评审课程学习总结
  9. 工行登录企业网银时,如遇“请确认您已插入工商银行U盾证书,或更换端口后再次尝试登录”提示的解决办法
  10. Centos 修改主机名称
  11. 雷曼 疯狂兔子 java_《雷曼:疯狂兔子》详细流程攻略+个人心得分享
  12. css rgb转16进制,jquery获取元素颜色css('color')的值返回RGB。如何转十六进制
  13. 闪瞎眼低效贪吃蛇:数组实现
  14. 线性代数笔记【空间向量】
  15. 我眼中的未来计算机作文1000字,我的未来作文1000字
  16. 关于nmap -O扫描中出现索尼手机的一份调研
  17. CAD手机看图软件中如何根据已知坐标点绘制线段?
  18. mac pro m1:安装dump文件内存分析工具——MAT
  19. html实现相册效果,图片播放(相册效果) - CSS实现
  20. Newtonsoft.Json序列化库

热门文章

  1. python输入圆的半径公式_[图文]铁路曲线正矢的计算公式
  2. 店铺咨询系统c语言,课内资源
  3. Linux下netstat常用,Linux netstat常用命令
  4. element走马灯自动_详细element-ui的走马灯carousel轻松实现自适应全屏banner详细过程...
  5. 多学一招总没错吧?SpringBoot解决前后端分离的跨域问题
  6. Ambari系统架构
  7. Redis(二):Redis入门与性能测试
  8. SpringBoot番外篇(一):使用Spring Initializer快速创建Spring Boot项目(IDEA版)
  9. Helloworld【C#】
  10. 问题 A: 深度学习