unicode string equivalent of contain

前端 未结 4 1179
长情又很酷
长情又很酷 2021-02-12 11:01

I have an error when trying to use contain in python.

s = u\"some utf8 words\"
k = u\"one utf8 word\"

if s.contains(k):
    print \"contains\" 
4条回答
  •  心在旅途
    2021-02-12 11:30

    There is no difference between str and unicode.

    print u"ábc" in u"some ábc"
    print "abc" in "some abc"
    

    is basically the same.

提交回复
热议问题