且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

() vs [] vs {} 之间有什么区别?

更新时间:2022-02-18 04:02:41

() - tuple

元组是一系列无法​​更改(不可变)的项目.

() - tuple

A tuple is a sequence of items that can't be changed (immutable).

列表是一系列可以更改(可变)的项目.

A list is a sequence of items that can be changed (mutable).

字典是键值对列表,具有唯一键(可变).从 Python 2.7/3.1 开始,{} 还可以表示一组唯一值(可变).

A dictionary is a list of key-value pairs, with unique keys (mutable). From Python 2.7/3.1, {} can also represent a set of unique values (mutable).