gpt4 book ai didi

python - python2.7 中 {"item1","item2",...} 的含义是什么

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:28 30 4
gpt4 key购买 nike

我对 python2.7 中的结构 {item1,item2,item3} 感到困惑。是一套吗?

我做了什么:

python2.7

同时

python2.3

那么,python2.7 中 {"item1","item2",...} 的含义是什么?

最佳答案

您可以使用 type() 函数检查对象的类型并弄清楚发生了什么:)

你会发现在python2.7中,a={1, 2, 3}是一个Set。你可能想知道“嘿,但是在 python2.3 中也有一个集合数据结构!”

嗯,语法略有不同:https://docs.python.org/2/library/sets.html

因此,在python2.7中,他们添加了语法糖来创建集合。

关于python - python2.7 中 {"item1","item2",...} 的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38004999/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com