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.pswp.cn/news/541514.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541514.shtml
英文地址,請注明出處:http://en.pswp.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…