You are not trying to covert a set
to an int
. You are merely trying to "pull" out the content of the set.
If you are certain the set contains only one element, you can use .pop
:
print({1}.pop())
will output
1
If the set contains more than a single element, every call to pop
will grab and return an arbitrary element from it.
Be careful, if the set is empty calling pop
on it will raise a keyError
exception.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…