mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
itemgetter add dict example (GH-1280)
This commit is contained in:
parent
04e8293465
commit
ffa2c3e2c4
1 changed files with 2 additions and 0 deletions
|
@ -315,6 +315,8 @@ expect a function argument.
|
|||
method. Dictionaries accept any hashable value. Lists, tuples, and
|
||||
strings accept an index or a slice:
|
||||
|
||||
>>> itemgetter('name')({'name': 'tu', 'age': 18})
|
||||
'tu'
|
||||
>>> itemgetter(1)('ABCDEFG')
|
||||
'B'
|
||||
>>> itemgetter(1,3,5)('ABCDEFG')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue