Why does comparison of bytes with str fails in Python3
问题 In Python3 this expression evaluates as False : b"" == "" while in Python2 this comparison is True : u"" == "" Checking for identity with is obviously fails in both cases. But why would they implement such a behaviour in Python3? 回答1: In Python 2.x, the design goal for unicode is to enable transparent operations between unicode & byte strings by implicitly converting between the 2 types. When you do the comparison u"" == "" , the unicode LHS is automatically encoded into a byte string first,