Creating a new dictionary in Python

后端 未结 7 2007
难免孤独
难免孤独 2020-11-29 15:17

I want to build a dictionary in Python. However, all the examples that I see are instantiating a dictionary from a list, etc . ..

How do I create a new empty diction

7条回答
  •  遥遥无期
    2020-11-29 15:25

    d = dict()
    

    or

    d = {}
    

    or

    import types
    d = types.DictType.__new__(types.DictType, (), {})
    

提交回复
热议问题