I wonder how to compare strings in Python.

Asked 2 years ago, Updated 2 years ago, 36 views

I wonder how to compare strings in Python.

str1 = "test"
str2 = "test"

print (str1 == str2)

This is the case of comparing only simple matches, as shown above.

When I searched, I couldn't find anything except ==.

Is there a function that functions similar to Java's equals?

python string

2022-09-22 08:46

1 Answers

There's an operator module

Among them, you can use it like Java equals using eq

(My environment is Python 3, but I'm not sure about 2. I guess so )


2022-09-22 08:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.