python中的{}和[]有什么区别? [英] What is the difference between {} and [] in 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 emptydict
columnNames = []
defines an emptylist
这些是根本不同的类型.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屋!
查看全文