Why is a tuple of tuples of length 1 not actually a tuple unless I add a comma?
问题 Given a tuple of tuples T : (('a', 'b')) and an individual tuple t1 : ('a','b') why does: t1 in T return False? UPDATE: From Ipython: In [22]: T = (('a','b')) In [23]: t1 = ('a','b') In [24]: t1 in T Out[24]: False And how then to check that a tuple is in another tuple? 回答1: The problem is because T is not a tuple of tuples, it is just a tuple. The comma makes a tuple, not the parentheses. Should be: >>> T = (('a','b'),) >>> t1 = ('a', 'b') >>> t1 in T True In fact, you can loose the outer