From: WeizhongTu Date: Fri, 13 Apr 2018 01:33:08 +0000 (+0800) Subject: itemgetter add dict example (GH-1280) X-Git-Tag: v3.8.0a1~1971 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d;p=python itemgetter add dict example (GH-1280) --- diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst index e4d6d05a23..250cbb6b7c 100644 --- a/Doc/library/operator.rst +++ b/Doc/library/operator.rst @@ -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')