DekGenius.com
Home
(current)
Dictionary
BOOKS
LYRICS
CHORD
SCRIPT & CODE EXAMPLE
Karaoke language
Search
Go
SCRIPT & CODE EXAMPLE
CODE EXAMPLE FOR PYTHON
python update dict if key not exist
d.setdefault('k1', 100) print(d) # {'k1': 1, 'k2': 2, 'k3': 3, 'k4': None}
Source by note.nkmk.me #
PREVIOUS
NEXT
Tagged:
#python
#update
#dict
#key
#exist
ADD COMMENT
Topic
COMMENT
Name
1+6 =
Submit