Last active
September 29, 2020 15:38
-
-
Save Gatsby-Lee/556e60b186ea985afc57b142858a2687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import collections | |
>>> import json | |
>>> d = collections.namedtuple("A", "a b c") | |
>>> d(a=1,b=2,c=3) | |
A(a=1, b=2, c=3) | |
>>> f = d(a=1,b=2,c=3) | |
>>> f | |
A(a=1, b=2, c=3) | |
>>> f._asdict() | |
OrderedDict([('a', 1), ('b', 2), ('c', 3)]) | |
>>> json.dumps(f._asdict()) | |
'{"a": 1, "b": 2, "c": 3}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment