Answers for "python dictiojnary"

2

python dictonary of dictonary

from collections import defaultdict
d = defaultdict(dict)
d['dict1']['innerkey'] = 'value'

>>> d  # currently a defaultdict type
defaultdict(<type 'dict'>, {'dict1': {'innerkey': 'value'}})
>>> dict(d)  # but is exactly like a normal dictionary.
{'dict1': {'innerkey': 'value'}}
Posted by: Guest on August-22-2021
0

python dict

>>> d = {}
>>> d
{}
>>> d = {'dict': 1, 'dictionary': 2}
>>> d
{'dict': 1, 'dictionary': 2}
Posted by: Guest on November-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language