Python efficient way to check if very large string contains a substring

后端 未结 8 1629
無奈伤痛
無奈伤痛 2021-01-02 05:04

Python is not my best language, and so I\'m not all that good at finding the most efficient solutions to some of my problems. I have a very large string (coming from a 30 MB

8条回答
  •  走了就别回头了
    2021-01-02 05:47

    small_string = "This is a line"
    big_string = "This is a line This is another line\nThis is yet another"
    
    test= big_string.split("This is a line" ,1)
    
    if len(test)==2:
    
        print "it`s there"
    
    elif len(test)!=2:
    
        print "it`s not"
    

提交回复
热议问题