python - 这些 Python 结构之间的区别

标签 python arrays list set

有什么区别:

things = []

things = {}

things = set()

我尝试使用谷歌搜索,但很难在不知道其实际名称的情况下通过谷歌搜索此类仅带有括号的结构来识别它们。

还有 (element1, element2) 我见过作为参数传递给函数的,但我不知道 Python 将其解释为什么。

最佳答案

这些是

  1. list
  2. dict
  3. set

欢迎使用 Python!

哦,我忘了说,如果你也是 Python 新手(甚至不是),我建议你查看 IPython .

当你对 python 什么都不懂的时候,就去做:

help(thing)

例如

help([]) # will show this ...
Help on list object:

class list(object)
 |  list() -> new empty list
 |  list(iterable) -> new list initialized from iterable's items
 |  

关于python - 这些 Python 结构之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21424241/

相关文章:

python - 压缩音频数据的快速方法?

python - 每行打印随机字数

python - 验证电子邮件未在 ubuntu 的本地服务器中使用 smtp 发送到电子邮件地址

python - 如何在列表理解中不向列表中添加任何内容?

c# - 如何使用 linq 映射两个列表

python - 没有模块名称pyspark错误

android:在 XML 中使用颜色数组

c++ - cin.getline() 在从函数中获取 char 时等效。

php - 如何使用 PHP 中的函数从全局数组中删除项目

c++ - std::list 中动态分配的数组导致内存泄漏