我无法将整数1
添加到现有集合。在交互式shell中,这是我正在做的:将数字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。
为什么你会尝试存储在一组真值,字符串和数字?你想解决什么问题? –