日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Python程序:向字典添加鍵值對(duì)

創(chuàng)新互聯(lián)python教程:

編寫(xiě)一個(gè) Python 程序,通過(guò)一個(gè)實(shí)際例子將鍵值對(duì)添加到字典中。

向字典添加鍵值對(duì)的 Python 程序示例 1

在這個(gè) python 程序中,我們使用字典更新功能將鍵值插入到字典中。

# Python Program to Add Key-Value Pair to a Dictionary

key = input("Please enter the Key : ")
value = input("Please enter the Value : ")

myDict = {}

# Add Key-Value Pair to a Dictionary in Python
myDict.update({key:value})
print("\nUpdated Dictionary = ", myDict)

將鍵值對(duì)插入字典的 Python 程序示例 2

這個(gè) Python 程序是將鍵值插入字典的另一種方法。

# Python Program to Add Key-Value Pair to a Dictionary

key = input("Please enter the Key : ")
value = input("Please enter the Value : ")

myDict = {}

# Add Key-Value Pair to a Dictionary in Python
myDict[key] = value
print("\nUpdated Dictionary = ", myDict)

向字典輸出添加鍵值對(duì)

Please enter the Key : M
Please enter the Value : Mango

Updated Dictionary =  {'M': 'Mango'}

網(wǎng)站名稱:Python程序:向字典添加鍵值對(duì)
分享URL:http://www.5511xx.com/article/dhshddj.html