mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Fix indentation in json.AttrDict
REPL example (#104930)
This is causing the docs to be rendered incorrectly.
This commit is contained in:
parent
1080c4386d
commit
38539ef126
1 changed files with 8 additions and 8 deletions
|
@ -559,14 +559,14 @@ Exceptions
|
|||
|
||||
.. doctest::
|
||||
|
||||
>>> json_string = '{"mercury": 88, "venus": 225, "earth": 365, "mars": 687}'
|
||||
>>> orbital_period = json.loads(json_string, object_hook=AttrDict)
|
||||
>>> orbital_period['earth'] # Dict style lookup
|
||||
365
|
||||
>>> orbital_period.earth # Attribute style lookup
|
||||
365
|
||||
>>> orbital_period.keys() # All dict methods are present
|
||||
dict_keys(['mercury', 'venus', 'earth', 'mars'])
|
||||
>>> json_string = '{"mercury": 88, "venus": 225, "earth": 365, "mars": 687}'
|
||||
>>> orbital_period = json.loads(json_string, object_hook=AttrDict)
|
||||
>>> orbital_period['earth'] # Dict style lookup
|
||||
365
|
||||
>>> orbital_period.earth # Attribute style lookup
|
||||
365
|
||||
>>> orbital_period.keys() # All dict methods are present
|
||||
dict_keys(['mercury', 'venus', 'earth', 'mars'])
|
||||
|
||||
Attribute style access only works for keys that are valid attribute
|
||||
names. In contrast, dictionary style access works for all keys. For
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue