【发布时间】:2012-05-02 18:53:58
【问题描述】:
我无法将整数 1 添加到现有集合中。在交互式外壳中,这就是我正在做的事情:
>>> st = {'a', True, 'Vanilla'}
>>> st
{'a', True, 'Vanilla'}
>>> st.add(1)
>>> st
{'a', True, 'Vanilla'} # Here's the problem; there's no 1, but anything else works
>>> st.add(2)
>>> st
{'a', True, 'Vanilla', 2}
这个问题是两个月前发布的,但我相信它被误解了。 我正在使用 Python 3.2.3。
【问题讨论】:
-
为什么要尝试将真值、字符串和数字存储在一个集合中?你想解决什么问题?
标签: python python-3.x set