Why in Python does “0, 0 == (0, 0)” equal “(0, False)”?

后端 未结 7 976
粉色の甜心
粉色の甜心 2020-12-04 09:20

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 elemen         


        
7条回答
  •  情话喂你
    2020-12-04 09:52

    look at this example:

    r = [1,0,1,0,1,1,0,0,0,1]
    print(r==0,0,r,1,0)
    print(r==r,0,1,0,1,0)
    

    then result:

    False 0 [1, 0, 1, 0, 1, 1, 0, 0, 0, 1] 1 0
    True 0 1 0 1 0
    

    then comparison just does to the first number(0 and r) in the example.

提交回复
热议问题