Python 数组(列表): 

thislist = ["apple", "banana", "cherry"]

  

Python 元组:

thistuple = ("apple", "banana", "cherry")

  

Python 集合:

thisset = {"apple", "banana", "cherry"}

  

Python字典:

thisdict =	{
  "brand": "Porsche",
  "model": "911",
  "year": 1963
}
print(thisdict)

Python 数组 元组 集合 字典  

1、元组是不可变的, 而列表、字典是可变的。元组是不可变对象,对象一旦生成,它的值将不能更改;列表是可变对象,对象生成后,可以对其元素进行更改、添加、删除、清空、排序等操作。

2、元组通常是由不同的数据,而列表是相同的数据队列。元组表示的是结构,而列表表示的是顺序。列表的权限远大于元组。

3、列表不能作为字典的key值,而元组可以。字典的键是唯一的。

相关文章:

  • 2021-04-17
  • 2022-02-02
  • 2021-04-19
  • 2022-12-23
  • 2021-08-27
  • 2021-05-19
  • 2021-10-24
  • 2021-12-26
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2021-06-01
  • 2021-10-28
  • 2021-09-14
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案