python中dict函数_dict()函数以及Python中的示例
python中dict函數(shù)
Python dict()函數(shù) (Python dict() function)
dict() function is a library function, it is used to create a dictionary with keywords( Ids) and values (s), it accepts a set of values with keywords, values and returns a dictionary.
dict()函數(shù)是一個(gè)庫(kù)函數(shù),用于創(chuàng)建帶有關(guān)鍵字(Ids)和值(s)的字典,它接受帶有關(guān)鍵字,值的一組值并返回字典。
Syntax:
句法:
dict(keyword1=value1, keyword2=value2, ...)Parameter(s): keyword1=value1, keyword2=value2, ... – a set of keywords and values to create a dictionary.
參數(shù): keyword1 = value1,keyword2 = value2,... –用于創(chuàng)建字典的一組關(guān)鍵字和值。
Return value: dict – returns dictionary.
返回值: dict –返回字典。
Example:
例:
Input:# creating dictionary std_info = dict(name = "Amit shukla", age = 21, course = "B.Tect (CS)")# printing the value of dictionary print("std_info:", std_info)Output:std_info: {'course': 'B.Tect (CS)', 'age': 21, 'name': 'Amit shukla'}Python code to create a dictionary
用Python代碼創(chuàng)建字典
# python code to demonstrate example of # dict() number# creating dictionary std_info = dict(name = "Amit shukla", age = 21, course = "B.Tect (CS)")# printing type print("type of std_info: ", type(std_info))# printing the value of dictionary print("std_info:", std_info)Output
輸出量
type of std_info: <class 'dict'> std_info: {'course': 'B.Tect (CS)', 'age': 21, 'name': 'Amit shukla'}翻譯自: https://www.includehelp.com/python/dict-function-with-example.aspx
python中dict函數(shù)
總結(jié)
以上是生活随笔為你收集整理的python中dict函数_dict()函数以及Python中的示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 《幽兰》第三句是什么
- 下一篇: python 全局_全局关键字,带Pyt