Home  >  Q&A  >  body text

Python determines whether strings are equal?


#Aren’t word and key equal? Why not perform the print operation and jump directly to the superposition of i?

女神的闺蜜爱上我女神的闺蜜爱上我2690 days ago1086

reply all(3)I'll reply

  • 代言

    代言2017-06-30 09:56:18

    You can’t tell the reason just by taking screenshots of these contents.
    You can add a print in else, firstly to see if else is entered, but also to see what the word and key are.

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-30 09:56:18

    What you see in the debuger of IDE may not be the real values. You can print out their type and have a look.
    You will find that debuger can sometimes lie.
    Also, you can look at the difference between __str__ and __repr__ and understand obj==eval(repr(obj)).
    Here’s a great answer: Difference between str and repr in Python

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-30 09:56:18

    Just use == to judge. . .

    Print it out to see if there are any encoding problems in the local and Linux environments. After pasting down the code, do you want us to type it again by hand? . .

    reply
    0
  • Cancelreply