Why in Python does “0, 0 == (0, 0)” equal “(0, False)”?
问题 In Python (I checked only with Python 3.6 but I believe it should hold for many of the previous versions as well): (0, 0) == 0, 0 # results in a two element tuple: (False, 0) 0, 0 == (0, 0) # results in a two element tuple: (0, False) (0, 0) == (0, 0) # results in a boolean True But: a = 0, 0 b = (0, 0) a == b # results in a boolean True Why does the result differ between the two approaches? Does the equality operator handle tuples differently? 回答1: The first two expressions both parse as