python系列之:字典update
生活随笔
收集整理的這篇文章主要介紹了
python系列之:字典update
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python系列之:字典update
- 一、字典不存在鍵值update
- 二、字典已經存在鍵值update
一、字典不存在鍵值update
字典不存在鍵值,使用update會添加鍵值對到字典中
account = "optics" decrypt_passwd = "12345abc"accountDict = {} accountDict.update({account:decrypt_passwd}) print(accountDict)輸出如下所示:
{‘optics’: ‘12345abc’}
二、字典已經存在鍵值update
字典已經存在鍵值update會更新鍵的值
account = "optics" decrypt_passwd = "abcdef"accountDict = {'optics': '12345abc'} accountDict.update({account:decrypt_passwd}) print(accountDict)輸出如下所示:
{‘optics’: ‘abcdef’}
總結
以上是生活随笔為你收集整理的python系列之:字典update的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git clone报错Could not
- 下一篇: 【Go语言】【17】GO语言杂谈