mirror of
https://github.com/python/cpython.git
synced 2024-12-01 05:45:40 +08:00
Doc: Add example of dict() function with positional and keyword arguments (GH-15220)
This commit is contained in:
parent
6e1a30b15e
commit
7544497ad3
@ -4213,7 +4213,8 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
|
|||||||
>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
|
>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
|
||||||
>>> d = dict([('two', 2), ('one', 1), ('three', 3)])
|
>>> d = dict([('two', 2), ('one', 1), ('three', 3)])
|
||||||
>>> e = dict({'three': 3, 'one': 1, 'two': 2})
|
>>> e = dict({'three': 3, 'one': 1, 'two': 2})
|
||||||
>>> a == b == c == d == e
|
>>> f = dict({'one': 1, 'three': 3}, two=2)
|
||||||
|
>>> a == b == c == d == e == f
|
||||||
True
|
True
|
||||||
|
|
||||||
Providing keyword arguments as in the first example only works for keys that
|
Providing keyword arguments as in the first example only works for keys that
|
||||||
|
Loading…
Reference in New Issue
Block a user