python中的{}和[]有什么区别?

python中的{}和[]有什么区别?

问题描述:

python中columnNames = {}columnNames = []有什么区别?

What is the difference between columnNames = {} and columnNames = [] in python?

我如何迭代每一个?使用 {% for value in columnNames %} OR for idx_o, val_o in enumerate(columnNames):

How can i iterate each one? using {% for value in columnNames %} OR for idx_o, val_o in enumerate(columnNames):

  • columnNames = {} 定义一个空的 dict
  • columnNames = [] 定义一个空的 list
    • columnNames = {} defines an empty dict
    • columnNames = [] defines an empty list
    • 这些是根本不同的类型.dict 是一个 关联数组,一个 list 是一个带有整数索引的标准数组.

      These are fundamentally different types. A dict is an associative array, a list is a standard array with integral indices.

      我建议您查阅参考资料,以更加熟悉这两种非常重要的 Python 容器类型.

      I recommend you consult your reference material to become more familiar with these two very important Python container types.