What's the difference between () vs [] vs {}?

后端 未结 4 766
轻奢々
轻奢々 2020-12-13 04:56

What\'s the difference between () vs [] vs {} in Python?
They\'re collections? How can I tell when to use which?

4条回答
  •  不知归路
    2020-12-13 05:23

    In addition to the tuple, list and dict given by the other answers, {} also denotes a set literal in python 2.7 and python 3.1. (This makes sense because set elements act like the keys of a dict).

提交回复
热议问题