unicode string equivalent of contain

前端 未结 4 1175
长情又很酷
长情又很酷 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:23

    Strings don't have "contain" attribute.

    s = "haha i am going home"
    s_new = s.split(' ')
    k = "haha"
    
    if k in s_new:
        print "contains"
    

    I guess you want to achieve this

提交回复
热议问题