“Python Dict Dot -Notation” Code-Antworten

Python Dict Dot -Notation

>>> from types import SimpleNamespace
>>> d = {'key1': 'value1', 'key2': 'value2'}
>>> n = SimpleNamespace(**d)
>>> print(n)
namespace(key1='value1', key2='value2')
>>> n.key2
'value2'
Sore Squirrel

Python Dict Dot -Notation

>>> from types import SimpleNamespace
>>> d = {'key1': 'value1', 'key2': 'value2'}
>>> n = SimpleNamespace(**d)
>>> print(n)
namespace(key1='value1', key2='value2')
>>> n.key2
'value2'
Yucky Yak

Ähnliche Antworten wie “Python Dict Dot -Notation”

Fragen ähnlich wie “Python Dict Dot -Notation”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen