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

前端 未结 8 505
陌清茗
陌清茗 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:21

    Basically, {} is syntax and is handled on a language and bytecode level. dict() is just another builtin with a more flexible initialization syntax. Note that dict() was only added in the middle of 2.x series.

提交回复
热议问题