Python “if X == Y and Z” syntax

前端 未结 7 2141
温柔的废话
温柔的废话 2020-12-06 17:10

Does this:

if key == \"name\" and item:

mean the same as this:

if key == \"name\" and if key == \"item\":

7条回答
  •  生来不讨喜
    2020-12-06 17:25

    If, hypothetically, you did want

    if key == "name" and if key == item:
    

    you could do this

    if key == "name" == item:
    

提交回复
热议问题