python中的{}和[]有什么区别? [英] What is the difference between {} and [] in python?

查看:63
本文介绍了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.

      这篇关于python中的{}和[]有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆