标签: python
将包含多个字符的切片字符串与另一个字符串is等于False进行比较。见Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?
is
False
但只比较1个字符切片与is等于True。为什么呢?
True
>>>> 'ab'[1:] is 'b' True >>>> 'abb'[1:] is 'bb' False