Python字典values()方法与示例

字典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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541514.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

spark源码分析之Executor启动与任务提交篇

任务提交流程 概述 在阐明了Spark的Master的启动流程与Worker启动流程。接下继续执行的就是Worker上的Executor进程了&#xff0c;本文继续分析整个Executor的启动与任务提交流程Spark-submit 提交一个任务到集群通过的是Spark-submit通过启动脚本的方式启动它的主类&#xff0…

mysql 5.5.22.tar.gz_MySQL 5.5.22源码编译安装

MySQL 最新的版本都需要cmake编译安装&#xff0c;估计以后的版本也会采用这种方式&#xff0c;所以特地记录一下安装步骤及过程&#xff0c;以供参考。注意&#xff1a;此安装是默认CentOS下已经安装了最新工具包&#xff0c;比如GNU make, GCC, Perl, libncurses5-dev&#x…

Java Vector setElementAt()方法与示例

向量类setElementAt()方法 (Vector Class setElementAt() method) setElementAt() method is available in java.util package. setElementAt()方法在java.util包中可用。 setElementAt() method is used to set the given element (ele) at the given indices in this Vector.…

利用python进行数据分析D2——ch03IPython

为无为,事无事,味无味。大小多少,报怨以德。图难于其易,为大于其细;天下难事必作于易,天下大事必作于细。——老子关于图片的例子&#xff1a;import matplotlib.pyplot as plt imgplt.imread(ch03/stinkbug.png) import pylab plt.imshow(img) pylab.show()结果&#xff1a;调…

mysql 视图 字典_MySQL深入01-SQL语言-数据字典-服务器变量-数据操作DML-视图

SQL语言的组成部分常见分类&#xff1a;DDL&#xff1a;数据定义语言DCL&#xff1a;数据控制语言&#xff0c;如授权DML&#xff1a;数据操作语言其它分类&#xff1a;完整性定义语言&#xff1a;DDL的一部分功能约束约束&#xff1a;包括主键&#xff0c;外键&#xff0c;唯一…

为什么我会被淘汰?

这是一个值得讨论的问题。华为前段时间也传出了大规模裁员的一些负面新闻&#xff0c;一时间搞的人心惶惶。总结起来说&#xff0c;还是怕失去这份赖以生存的工作&#xff0c;尤其是对于上有老下有小的中年人来说&#xff0c;工作尤为重要。 淘汰&#xff0c;是软件行业不变的真…

Java Throwable initCause()方法与示例

Throwable类initCause()方法 (Throwable Class initCause() method) initCause() Method is available in java.lang package. initCause()方法在java.lang包中可用。 initCause() Method is used to instantiate the cause of this throwable to the given value and this met…

mysql 存储过程死循环_pl/sql存储过程loop死循环

今早&#xff0c;一个存储过程&#xff0c;写过很多次的存储过程&#xff0c;随手一写&#xff0c;各种报错&#xff0c;各种纠结&#xff0c;网上一搜&#xff0c;有好多个都遇到&#xff0c;论坛上给出的结局答案&#xff0c;今早&#xff0c;一个存储过程&#xff0c;写过很…

GATK之VariantAnnotator

VariantAnnotator 简要说明 用途&#xff1a; 利用上下文信息注释识别的变异位点(variant calls)分类&#xff1a; 变异位点操作工具概要&#xff1a; 根据变异位点的背景信息&#xff08;与功能注释相对&#xff09;进行注释。目前有许多的注释模块&#xff08;见注释模块一节…

pipedreader_Java PipedReader connect()方法与示例

pipedreaderPipedReader类的connect()方法 (PipedReader Class connect() method) connect() method is available in java.io package. connect()方法在java.io包中可用。 connect() method is used to cause this PipedReader to be connected to the given PipedWriter (sou…

《Java学习指南》—— 1.4 设计安全

本节书摘来异步社区《Java学习指南》一书中的第1章&#xff0c;第1.4节&#xff0c;作者&#xff1a;【美】Patrick Niemeyer , Daniel Leuck&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.4 设计安全 Java被设计为一种安全语言&#xff0c;对于这一事实…

ppython_Python pcom包_程序模块 - PyPI - Python中文网

PCOM在python中一个非常基本的unitronics pcom协议实现。如何使用from pcom import commandsfrom pcom.plc import EthernetPlcwith EthernetPlc(address(192.168.5.43, 1616)) as plc:# Read realtime clockc commands.ReadRtc()res plc.send(c)print(res)# Set realtime cl…

bitcount方法详解_Java Long类的bitCount()方法和示例

bitcount方法详解长类bitCount()方法 (Long class bitCount() method) bitCount() method is available in java.lang package. bitCount()方法在java.lang包中可用。 bitCount() method is used to find the number of 1s bits in the 2s complement binary denotation of the…

《软件定义数据中心:Windows Server SDDC技术与实践》——导读

前言 通过对自身的审视和对身边IT 技术专家的观察&#xff0c;我发现对于我们来说&#xff0c;掌握一项新的技术或熟悉一个新的产品&#xff0c;大都是闻而后知&#xff0c;知而后学&#xff0c;学以致用&#xff0c;用以知其然。然而Windows Server作为一个简单的、易上手的操…

python二维向量运算模拟_python二维向量运算_[VB.NET][C#]二维向量的基本运算

前言在数学中&#xff0c;几何向量是指具有大小和方向的几何对象。在编程中&#xff0c;向量有着广泛的应用&#xff0c;其作用在图形编程和游戏物理引擎方面尤为突出。第一节 构造函数通过创建一个二维向量的类(或结构体)&#xff0c;实现向量的表示及其运算。1. 首先&#xf…

Java LinkedHashMap clear()方法与示例

LinkedHashMap类的clear()方法 (LinkedHashMap Class clear() method) clear() method is available in java.util package. clear()方法在java.util包中可用。 clear() method is used to remove all the existing elements from this LinkedHashMap. clear()方法用于从此Link…

《Imperfect C++中文版》——1.3 运行期契约:前置条件、后置条件和不变式

本节书摘来自异步社区出版社《Imperfect C中文版》一书中的第1章&#xff0c;第1.3节&#xff0c;作者&#xff1a; 【美】Matthew Wilson&#xff0c;更多章节内容可以访问云栖社区“异步社区”公众号查看。 1.3 运行期契约&#xff1a;前置条件、后置条件和不变式 Imperfect …

python名称空间与运用域_Python名称空间和作用域讲座,命名,Namespaces,Scopes

Python命名空间(Namespaces)和作用域(Scopes)讲座命名空间(Namespace)命名空间(Namespace)&#xff0c;是名称到对象的映射。命名空间提供了在项目中避免名字冲突的一种方法。命名空间是独立的&#xff0c;没有任何关系的&#xff0c;所以一个命名空间中不能有重名&#xff0c;…

getminimum_Java Calendar getMinimum()方法与示例

getminimumCalendar类的getMinimum()方法 (Calendar Class getMinimum() method) getMinimum() method is available in java.util package. getMinimum()方法在java.util包中可用。 getMinimum() method is used to get the minimum value of the given field(fi) of this Cal…

《Spark核心技术与高级应用》——3.2节构建Spark的开发环境

本节书摘来自华章社区《Spark核心技术与高级应用》一书中的第3章&#xff0c;第3.2节构建Spark的开发环境&#xff0c;作者于俊 向海 代其锋 马海平&#xff0c;更多章节内容可以访问云栖社区“华章社区”公众号查看 3.2 构建Spark的开发环境无论Windows或Linux操作系统&am…