What's the difference between dict() and {}?

前端 未结 8 471
陌清茗
陌清茗 2020-12-12 13:53

So let\'s say I wanna make a dictionary. We\'ll call it d. But there are multiple ways to initialize a dictionary in Python! For example, I could do this:

8条回答
  •  时光取名叫无心
    2020-12-12 14:27

    dict() is used when you want to create a dictionary from an iterable, like :

    dict( generator which yields (key,value) pairs )
    dict( list of (key,value) pairs )
    

提交回复
热议问题