-
Python Dictionary setdefault() Method
The
setdefault()
method returns the value of the item with the specified key.If the key does not exist, insert the key, with the specified value.
dictionary.setdefault(keyname, value)
-
keyname
: Required. The keyname of the item you want to return the value from -
value
: Optional. If the key exist, this parameter has no effect.
If the key does not exist, this value becomes the key’s value.
Default value None.
-
-
References
理解dict.setdefault() in Python
最新推荐文章于 2024-09-22 23:46:11 发布