亚洲熟女综合色一区二区三区,亚洲精品中文字幕无码蜜桃,亚洲va欧美va日韩va成人网,亚洲av无码国产一区二区三区,亚洲精品无码久久久久久久

字典訪問操作【每日一個知識點(diǎn)第185期-Python】

把相應(yīng)的鍵放入到方括號中,如下實(shí)例:

#!/usr/bin/Python3

dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'}

print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])

以上實(shí)例輸出結(jié)果:

dict['Name']:  Runoob
dict['Age']:  7

如果用字典里沒有的鍵訪問數(shù)據(jù),會輸出錯誤如下:

#!/usr/bin/Python3
 
dict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'};
 
print ("dict['Alice']: ", dict['Alice'])

以上實(shí)例輸出結(jié)果:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    print ("dict['Alice']: ", dict['Alice'])
KeyError: 'Alice'

Python入門每日一個知識點(diǎn)》欄目是馬哥教育Python年薪20萬+的學(xué)員社群特別發(fā)起,分享Python工具、Python語法、Python項(xiàng)目等知識點(diǎn),幫助大家快速的了解Python學(xué)習(xí),快速步入Python高薪的快車道。

http://www.vfuj.cn/73198.html

相關(guān)新聞

歷經(jīng)多年發(fā)展,已成為國內(nèi)好評如潮的Linux云計(jì)算運(yùn)維、SRE、Devops、網(wǎng)絡(luò)安全、云原生、Go、Python開發(fā)專業(yè)人才培訓(xùn)機(jī)構(gòu)!